

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    
        <html xmlns="http://www.w3.org/1999/xhtml">
    
<head>
        <link rel="canonical" href="http://blog.csdn.net/guyuealian/article/details/78730200" />

    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="alternate" media="handheld" href="#" />

    <meta name="shenma-site-verification" content="5a59773ab8077d4a62bf469ab966a63b_1497598848" />

    <title>Python 3 多线程下载百度图片搜索结果 - guyuealian的博客 - CSDN博客</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="description" content="Python 3 实现下载百度图片搜索结果转载来至：http://lovenight.github.io/2015/11/15/Python-3-%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C/下载简单页面查看网" />

    <meta name="keywords" content="" />
    <script src="http://static.blog.csdn.net/scripts/blog_static_head.min.js?v2" type="text/javascript"></script>


        <link rel="Stylesheet" type="text/css" href="http://static.blog.csdn.net/skin/skin-yellow/css/style.css?v=2.3" />

    

    <link id="RSSLink" title="RSS" type="application/rss+xml" rel="alternate" href="/guyuealian/rss/list" />
    <link rel="shortcut icon" href="http://c.csdnimg.cn/public/favicon.ico" />
    <link type="text/css" rel="stylesheet" href="http://static.blog.csdn.net/scripts/SyntaxHighlighter/styles/default.css" />





    <link href="http://c.csdnimg.cn/blog/csdn_public_blog_detail.min.css" type="text/css" rel="stylesheet" />

        <link rel="stylesheet" href="http://static.blog.csdn.net/css/csdn_blog_detail.min.css" />

    <!-- 请置于所有广告位代码之前 -->
    <script src="http://dup.baidustatic.com/js/ds.js"></script>

</head>


<body>
        <div class="csdn-tracking-statistics" data-pid="blog" data-view="true" data-mod="ad_popu_72" data-mtp="62" data-order="40" data-con="ad_content_2072">
            <script id="popuLayer_js_q" src="http://ads.csdn.net/js/popuLayer.js" defer="defer" type="text/javascript"></script>
            <div id="layerd" style="position: fixed;bottom:0px;right:0px;line-height:0px;z-index:1000">
                <div class="J_close layer_close" style="display:;background-color:#efefef;padding:0px;color:#333;font:12px/24px Helvetica,Tahoma,Arial,sans-serif;text-align:right;">关闭</div><!-- 广告占位容器 -->
                <div id="cpro_u2895327">
                    <!-- 投放代码 -->
                            <script type="text/javascript" src="//cee1.iteye.com/ojylrgbyk.js"></script>



                </div>
            </div>
            <script>
                document.getElementById("popuLayer_js_q").onload = function () {
                    var styObjd = styObj = { width: "300px", "height": parseInt(250) + 28 };
                    window.CSDN.Layer.PopuLayer("#layerd", { storageName: "layerd", styleObj: styObjd, total: 50, expoire: 1000 * 60 });
                }</script>


        </div>


    <!--new top-->
    <script id="toolbar-tpl-scriptId" src="http://csdnimg.cn/public/common/toolbar/js/content_toolbar.js" type="text/javascript" domain="http://blog.csdn.net"></script>

    <link rel="stylesheet" href="http://csdnimg.cn/public/common/toolbar/content_toolbar_css/content_toolbar.css">
    <!--new top-->
    <div id="container">
        
<div id="header">
    <div class="header">
        <div id="blog_title">
            <h2>
                <a href="http://blog.csdn.net/guyuealian">guyuealian的博客</a></h2>
            <h3></h3>
            <div class="clear">
            </div>
        </div>
        <div class="clear">
        </div>
        
    
    </div>
</div>
<div id="navigator">
    <div class="navigator_bg">
    </div>
    <div class="navigator">
        <ul>           
                <li id="btnContents"><a href="http://blog.csdn.net/guyuealian?viewmode=contents"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_mulu'])">
                    <img src="http://static.blog.csdn.net/images/ico_list.gif">目录视图</span></a></li>
                <li id="btnView"><a href="http://blog.csdn.net/guyuealian?viewmode=list"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_zhaiyao'])">
                    <img src="http://static.blog.csdn.net/images/ico_summary.gif">摘要视图</span></a></li>
                <li id="btnRss"><a href="http://blog.csdn.net/guyuealian/rss/list"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_RSS'])">
                    <img src="http://static.blog.csdn.net/images/ico_rss.gif">订阅</span></a></li>                   
            

            </ul>
    </div>
</div>
<script type="text/javascript">
    var username = "guyuealian";
    var _blogger = username;
    var blog_address = "http://blog.csdn.net/guyuealian";
    var static_host = "http://static.blog.csdn.net";
    var currentUserName = "";  
	var curUserFace = "http://avatar.csdn.net/2_guest.jpg";
</script>

        <div id="body">
            <div id="main">
                <div class="main">
                    <div class="ad_class">



                    </div>

                    

 <script src="http://csdnimg.cn/rabbit/exposure-click/main-1.0.5.js"></script>

<script   type="text/javascript" src="http://static.blog.csdn.net/scripts/category.js"></script>

  <script type="text/ecmascript">
      var title="Python 3 多线程下载百度图片搜索结果";
      window.quickReplyflag = true;
      var isBole = false; 
      var fasrc="http://my.csdn.net/my/favorite/miniadd?t=Python+3+%e5%a4%9a%e7%ba%bf%e7%a8%8b%e4%b8%8b%e8%bd%bd%e7%99%be%e5%ba%a6%e5%9b%be%e7%89%87%e6%90%9c%e7%b4%a2%e7%bb%93%e6%9e%9c&u=http://blog.csdn.net/guyuealian/article/details/78730200"
    </script>
<style>
    .texCommend {
        position: absolute;
        background-color: #fff;
        color: #000;
        padding: 5px;
        border: 1px solid #ccc;
        cursor: default;
        text-align: left;
        z-index: 201;
        border-radius: 5px;
        box-shadow: 0 10px 20px #808080;
        font-size: 12px;
        line-height: 1.5;
    }
    .MJX_Assistive_MathML {
        display: none;
    }
    span.MathJax {
        outline: none
    }
</style>
<div id="article_details" class="details">
    
<div class="article_title">   
         <span class="ico ico_type_Repost"></span>

    <h1>
        <span class="link_title"><a href="/guyuealian/article/details/78730200">
        Python 3 多线程下载百度图片搜索结果        
           
        </a>
        </span>

         
    </h1>
</div>


    
    <div class="article_manage clearfix">
        <div class="article_r">
            <span class="link_postdate">2017-12-06 14:17</span>
            <span class="link_view" title="阅读次数">444人阅读</span>
            <span class="link_comments" title="评论次数"> <a href="#comments" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_pinglun'])">评论</a>(0)</span>
            <span class="link_collect csdn-tracking-statistics" data-pid="blog"  data-mod="popu_171"> <a href="javascript:void(0);" onclick="javascript:collectArticle('Python+3+%e5%a4%9a%e7%ba%bf%e7%a8%8b%e4%b8%8b%e8%bd%bd%e7%99%be%e5%ba%a6%e5%9b%be%e7%89%87%e6%90%9c%e7%b4%a2%e7%bb%93%e6%9e%9c','78730200');return false;" title="收藏">收藏</a></span>
             <span class="link_report"> <a href="#report" onclick="javascript:report(78730200,2);return false;" title="举报">举报</a></span>

        </div>
    </div>    <style type="text/css">        
            .embody{
                padding:10px 10px 10px;
                margin:0 -20px;
                border-bottom:solid 1px #ededed;                
            }
            .embody_b{
                margin:0 ;
                padding:10px 0;
            }
            .embody .embody_t,.embody .embody_c{
                display: inline-block;
                margin-right:10px;
            }
            .embody_t{
                font-size: 12px;
                color:#999;
            }
            .embody_c{
                font-size: 12px;
            }
            .embody_c img,.embody_c em{
                display: inline-block;
                vertical-align: middle;               
            }
             .embody_c img{               
                width:30px;
                height:30px;
            }
            .embody_c em{
                margin: 0 20px 0 10px;
                color:#333;
                font-style: normal;
            }
    </style>
    <script  type="text/javascript">
        $(function () {
            try
            {
                var lib = eval("("+$("#lib").attr("value")+")");
                var html = "";
                if (lib.err == 0) {
                    $.each(lib.data, function (i) {
                        var obj = lib.data[i];
                        //html += '<img src="' + obj.logo + '"/>' + obj.name + "&nbsp;&nbsp;";
                        html += ' <a href="' + obj.url + '" target="_blank">';
                        html += ' <img src="' + obj.logo + '">';
                        html += ' <em><b>' + obj.name + '</b></em>';
                        html += ' </a>';
                    });
                    if (html != "") {
                        setTimeout(function () {
                            $("#lib").html(html);                      
                            $("#embody").show();
                        }, 100);
                    }
                }      
            } catch (err)
            { }
            
        });
    </script>
      <div class="category clearfix">
        <div class="category_l">
           <img src="http://static.blog.csdn.net/images/category_icon.jpg">
            <span>分类：</span>
        </div>
        <div class="category_r">
                    <label  onclick="GetCategoryArticles('6428363','guyuealian','top','78730200');">
                        <span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_fenlei']);">Python<em>（4）</em></span>
                      <img class="arrow-down" src="http://static.blog.csdn.net/images/arrow_triangle _down.jpg" style="display:inline;">
                      <img class="arrow-up" src="http://static.blog.csdn.net/images/arrow_triangle_up.jpg" style="display:none;">
                        <div class="subItem">
                            <div class="subItem_t"><a  href="http://blog.csdn.net/guyuealian/article/category/6428363"  target="_blank">作者同类文章</a><i class="J_close">X</i></div>
                            <ul class="subItem_l" id="top_6428363">                            
                            </ul>
                        </div>
                    </label>                    
        </div>
    </div>






<div id="article_content" class="article_content csdn-tracking-statistics" data-pid="blog"  data-mod=popu_307  data-dsm = "post" >
<h1 style="text-align: center; margin: 20px 0px 15px; padding: 10px 0px 0px; line-height: 1.5; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 20px; color: rgb(85, 85, 85);">Python 3 多线程下载百度图片搜索结果</h1><pre style="text-align: left; margin: 20px 0px 15px; padding: 10px 0px 0px; line-height: 1.5; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; color: rgb(85, 85, 85);"><span style="font-size:12px;">转载来至：http://lovenight.github.io/2015/11/15/Python-3-%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C/</span></pre><h2 id="下载简单页面" style="margin: 20px 0px 15px; padding: 10px 0px 0px; line-height: 1.5; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 20px; color: rgb(85, 85, 85); text-align: justify;">下载简单页面</h2><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">查看网页源码，发现同一张图片有四种网址：</p><a target=_blank target="_blank" id="more" style="color: rgb(5, 147, 211); border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"></a><span style="color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"></span><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 20px; margin-bottom: 20px; padding: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; text-align: justify;"><code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; padding: 0px; word-break: break-all; background: none; border-radius: 4px; text-shadow: none;">&quot;thumbURL&quot;: &quot;http://img1.imgtn.bdimg.com/it/u=<span class="number" style="color: rgb(209, 241, 169);">757023778</span>,<span class="number" style="color: rgb(209, 241, 169);">2840825931</span>&amp;fm=21&amp;gp=0.jpg&quot;,
&quot;middleURL&quot;: &quot;http://img1.imgtn.bdimg.com/it/u=<span class="number" style="color: rgb(209, 241, 169);">757023778</span>,<span class="number" style="color: rgb(209, 241, 169);">2840825931</span>&amp;fm=21&amp;gp=0.jpg&quot;,
&quot;hoverURL&quot;: &quot;http://img1.imgtn.bdimg.com/it/u=<span class="number" style="color: rgb(209, 241, 169);">757023778</span>,<span class="number" style="color: rgb(209, 241, 169);">2840825931</span>&amp;fm=23&amp;gp=0.jpg&quot;,
&quot;objURL&quot;: &quot;http://imgsrc.baidu.com/forum/w=580/sign=b3bcc<span class="number" style="color: rgb(209, 241, 169);">2f88a5494</span>ee<span class="number" style="color: rgb(209, 241, 169);">87220f111</span>df<span class="number" style="color: rgb(209, 241, 169);">4e0e1/78</span>fed309b3de<span class="number" style="color: rgb(209, 241, 169);">9c82913</span>abac<span class="number" style="color: rgb(209, 241, 169);">86a81800a18</span>d84344.jpg&quot;,
</code></pre><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">经测试，前三种都有反爬虫措施，用浏览器可以打开，但是刷新一次就403 Forbidden。用爬虫获取不到图片。</p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">第四种objURL是指图片的源网址，获取该网址会出现三种情况：</p><ol style="color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"><li>正常。继续下载</li><li>403 Forbidden。用continue跳过。</li><li>出现异常。用try except处理。</li></ol><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">代码如下：</p><figure class="highlight python" style="margin: 20px 0px; overflow: auto; padding: 15px; font-size: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; text-align: justify;"><table style="border-collapse: collapse; border-spacing: 0px; margin: 0px; width: auto; border: none; font-size: 14px; table-layout: fixed;"><tbody><tr style="background-color: rgb(249, 249, 249);"><td class="gutter" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px 20px 1px 1px; color: rgb(102, 102, 102); background: rgb(0, 36, 81); line-height: 1.6; border: none; text-align: right;"><span class="line" style="height: 20px;">1</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">2</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">3</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">4</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">5</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">6</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">7</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">8</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">9</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">10</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">11</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">12</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">13</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">14</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">15</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">16</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">17</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">18</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">19</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">20</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">21</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">22</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">23</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">24</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">25</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">26</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">27</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">28</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">29</span><br data-filtered="filtered" /></pre></td><td class="code" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; border: none;"><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> requests</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> re</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> os</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">url = <span class="string" style="color: rgb(209, 241, 169);">r'http://image.baidu.com/search/index?tn=baiduimage&amp;ipn=r&amp;ct=201326592&amp;cl=2&amp;lm=-1&amp;st=-1&amp;fm=detail&amp;fr=&amp;sf=1&amp;fmq=1447473655189_R&amp;pv=&amp;ic=0&amp;nc=1&amp;z=&amp;se=&amp;showtab=0&amp;fb=0&amp;width=&amp;height=&amp;face=0&amp;istype=2&amp;ie=utf-8&amp;word=%E9%95%BF%E8%80%85%E8%9B%A4'</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">dirpath = <span class="string" style="color: rgb(209, 241, 169);">r'F:\img'</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">html = requests.get(url).text</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">urls = re.findall(<span class="string" style="color: rgb(209, 241, 169);">r'&quot;objURL&quot;:&quot;(.*?)&quot;'</span>, html)</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">if</span> <span class="keyword" style="color: rgb(235, 187, 255);">not</span> os.path.isdir(dirpath):</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    os.mkdir(dirpath)</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">index = <span class="number" style="color: rgb(209, 241, 169);">1</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">for</span> url <span class="keyword" style="color: rgb(235, 187, 255);">in</span> urls:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    print(<span class="string" style="color: rgb(209, 241, 169);">&quot;Downloading:&quot;</span>, url)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">try</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        res = requests.get(url)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">if</span> str(res.status_code)[<span class="number" style="color: rgb(209, 241, 169);">0</span>] == <span class="string" style="color: rgb(209, 241, 169);">&quot;4&quot;</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            print(<span class="string" style="color: rgb(209, 241, 169);">&quot;未下载成功：&quot;</span>, url)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">continue</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">except</span> Exception <span class="keyword" style="color: rgb(235, 187, 255);">as</span> e:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        print(<span class="string" style="color: rgb(209, 241, 169);">&quot;未下载成功：&quot;</span>, url)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    filename = os.path.join(dirpath, str(index) + <span class="string" style="color: rgb(209, 241, 169);">&quot;.jpg&quot;</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">with</span> open(filename, <span class="string" style="color: rgb(209, 241, 169);">'wb'</span>) <span class="keyword" style="color: rgb(235, 187, 255);">as</span> f:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        f.write(res.content)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        index += <span class="number" style="color: rgb(209, 241, 169);">1</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">print(<span class="string" style="color: rgb(209, 241, 169);">&quot;下载结束，一共 %s 张图片&quot;</span> % index)</span><br data-filtered="filtered" /></pre></td></tr></tbody></table></figure><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"><a target=_blank target="_blank" href="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C%E4%B8%8B%E8%BD%BD%E7%BB%93%E6%9E%9C1.png" class="fancybox" rel="group" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;"><img src="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C%E4%B8%8B%E8%BD%BD%E7%BB%93%E6%9E%9C1.png" alt="下载结果" style="border: 1px solid rgb(221, 221, 221); display: block !important; margin: 0px auto; max-width: 100%; height: auto; cursor: -webkit-zoom-in; box-sizing: border-box; padding: 3px;" /></a></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">Exciting！</p><h2 id="加载更多图片" style="margin: 20px 0px 15px; padding: 10px 0px 0px; line-height: 1.5; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 20px; color: rgb(85, 85, 85); text-align: justify;">加载更多图片</h2><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">但是上面的代码还有不足，当我们在网页中下拉时，百度会继续加载更多图片。需要再完善一下代码。</p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">打开Chrome，按F12，切换到Network标签，然后将网页向下拉。这时浏览器地址栏的网址并没有改变，而网页中的图片却一张张增加，说明网页在后台与服务器交互数据。警察蜀黍，就是这家伙：<br data-filtered="filtered" /><a target=_blank target="_blank" href="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9CF12.png" class="fancybox" rel="group" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;"><img src="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9CF12.png" alt="Chrome 抓包" style="border: 1px solid rgb(221, 221, 221); display: block !important; margin: 0px auto; max-width: 100%; height: auto; cursor: -webkit-zoom-in; box-sizing: border-box; padding: 3px;" /></a></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">xhr全称XMLHttpRequest，详细介绍见百度：<a target=_blank target="_blank" href="http://baike.baidu.com/link?url=59cVUdY8JuhiQ1NBfELSH93H_HFlTg9YoC5cqnjuyIvVHcyqx92fVNLTUWfvq8lesK5-h9HXgmbVuQseom0qu_" rel="external" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;">XMLHTTPRequest_百度百科</a></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">点开看看：<br data-filtered="filtered" /><a target=_blank target="_blank" href="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9CRequestURL.png" class="fancybox" rel="group" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;"><img src="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9CRequestURL.png" alt="Request URL" style="border: 1px solid rgb(221, 221, 221); display: block !important; margin: 0px auto; max-width: 100%; height: auto; cursor: -webkit-zoom-in; box-sizing: border-box; padding: 3px;" /></a></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">这么长一串网址，没有头绪。下拉网页，再抓一个xhr，对比一下它们的Request URL，使用在线文字对比工具：<a target=_blank target="_blank" href="http://home.putclub.com/tools/find/" rel="external" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;">文本比较</a><br data-filtered="filtered" /><a target=_blank target="_blank" href="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C%E6%96%87%E6%9C%AC%E5%AF%B9%E6%AF%94%E7%BB%93%E6%9E%9C.png" class="fancybox" rel="group" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;"><img src="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C%E6%96%87%E6%9C%AC%E5%AF%B9%E6%AF%94%E7%BB%93%E6%9E%9C.png" alt="文本对比结果" style="border: 1px solid rgb(221, 221, 221); display: block !important; margin: 0px auto; max-width: 100%; height: auto; cursor: -webkit-zoom-in; box-sizing: border-box; padding: 3px;" /></a></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">URL末尾有三处变化，最后一项看上去是时间戳，经过测试，直接把它删了也没事。</p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">那么只需要研究<code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">pn</code>和<code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">gsm</code>值。继续下拉，到底的时候点<code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">加载更多图片</code>，多抓几个对比一下URL的末尾部分：</p><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 20px; margin-bottom: 20px; padding: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; text-align: justify;"><code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; padding: 0px; word-break: break-all; background: none; border-radius: 4px; text-shadow: none;">pn=<span class="number" style="color: rgb(209, 241, 169);">120</span>&amp;rn=<span class="number" style="color: rgb(209, 241, 169);">60</span>&amp;gsm=<span class="number" style="color: rgb(209, 241, 169);">78</span>
pn=<span class="number" style="color: rgb(209, 241, 169);">180</span>&amp;rn=<span class="number" style="color: rgb(209, 241, 169);">60</span>&amp;gsm=b4
pn=<span class="number" style="color: rgb(209, 241, 169);">240</span>&amp;rn=<span class="number" style="color: rgb(209, 241, 169);">60</span>&amp;gsm=f0
pn=<span class="number" style="color: rgb(209, 241, 169);">300</span>&amp;rn=<span class="number" style="color: rgb(209, 241, 169);">60</span>&amp;gsm=<span class="number" style="color: rgb(209, 241, 169);">12</span>c
pn=<span class="number" style="color: rgb(209, 241, 169);">360</span>&amp;rn=<span class="number" style="color: rgb(209, 241, 169);">60</span>&amp;gsm=<span class="number" style="color: rgb(209, 241, 169);">168</span>
</code></pre><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"><code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">pn</code>是一个60为步长的等差数列。<code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">gsm</code>看上去是16进制，转换成十进制，发现它就是<code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">pn</code>值，试了也可以删掉。</p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">经测试，<code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">rn</code>是步长值，最大只能取60，填入大于60的数，仍然以60为步长。如果删了<code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">rn</code>，则步长值变为30。<code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">pn</code>是图片编号，从0开始。</p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">现在已经删了时间戳和<code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">gsm</code>两项了，能不能让网址再短一点？继续观察，注意到：</p><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 20px; margin-bottom: 20px; padding: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; text-align: justify;"><code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; padding: 0px; word-break: break-all; background: none; border-radius: 4px; text-shadow: none;">&amp;se=&amp;tab=&amp;<span class="variable" style="color: rgb(255, 157, 164);">width</span>=&amp;<span class="variable" style="color: rgb(255, 157, 164);">height</span>=
</code></pre><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">这几项没指定值，肯定没用，把没值的都删了。</p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">再看看这两项：</p><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 20px; margin-bottom: 20px; padding: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; text-align: justify;"><code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; padding: 0px; word-break: break-all; background: none; border-radius: 4px; text-shadow: none;">queryWord=<span class="preprocessor" style="color: rgb(255, 197, 143);">%</span>E<span class="number" style="color: rgb(209, 241, 169);">9</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span><span class="number" style="color: rgb(209, 241, 169);">95</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span>BF<span class="preprocessor" style="color: rgb(255, 197, 143);">%</span>E<span class="number" style="color: rgb(209, 241, 169);">8</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span><span class="number" style="color: rgb(209, 241, 169);">80</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span><span class="number" style="color: rgb(209, 241, 169);">85</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span>E<span class="number" style="color: rgb(209, 241, 169);">8</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span><span class="number" style="color: rgb(209, 241, 169);">9</span>B<span class="preprocessor" style="color: rgb(255, 197, 143);">%</span>A<span class="number" style="color: rgb(209, 241, 169);">4</span>
word=<span class="preprocessor" style="color: rgb(255, 197, 143);">%</span>E<span class="number" style="color: rgb(209, 241, 169);">9</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span><span class="number" style="color: rgb(209, 241, 169);">95</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span>BF<span class="preprocessor" style="color: rgb(255, 197, 143);">%</span>E<span class="number" style="color: rgb(209, 241, 169);">8</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span><span class="number" style="color: rgb(209, 241, 169);">80</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span><span class="number" style="color: rgb(209, 241, 169);">85</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span>E<span class="number" style="color: rgb(209, 241, 169);">8</span><span class="preprocessor" style="color: rgb(255, 197, 143);">%</span><span class="number" style="color: rgb(209, 241, 169);">9</span>B<span class="preprocessor" style="color: rgb(255, 197, 143);">%</span>A<span class="number" style="color: rgb(209, 241, 169);">4</span>
</code></pre><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">这就是我们本次搜索的关键词。网址中的中文会被编码成UTF-8，每个中文3个字节，每个字节前加上%号。编码和解码方法如下：<br data-filtered="filtered" /><a target=_blank target="_blank" href="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C%E4%B8%AD%E6%96%87%E7%BC%96%E7%A0%81%E8%A7%A3%E7%A0%81.png" class="fancybox" rel="group" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;"><img src="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C%E4%B8%AD%E6%96%87%E7%BC%96%E7%A0%81%E8%A7%A3%E7%A0%81.png" alt="中文编码解码" style="border: 1px solid rgb(221, 221, 221); display: block !important; margin: 0px auto; max-width: 100%; height: auto; cursor: -webkit-zoom-in; box-sizing: border-box; padding: 3px;" /></a></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">那么，我们可以写出指定关键词需要请求的所有网址：<br data-filtered="filtered" /></p><figure class="highlight python" style="margin: 20px 0px; overflow: auto; padding: 15px; font-size: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; text-align: justify;"><table style="border-collapse: collapse; border-spacing: 0px; margin: 0px; width: auto; border: none; font-size: 14px; table-layout: fixed;"><tbody><tr style="background-color: rgb(249, 249, 249);"><td class="gutter" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px 20px 1px 1px; color: rgb(102, 102, 102); background: rgb(0, 36, 81); line-height: 1.6; border: none; text-align: right;"><span class="line" style="height: 20px;">1</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">2</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">3</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">4</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">5</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">6</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">7</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">8</span><br data-filtered="filtered" /></pre></td><td class="code" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; border: none;"><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> itertools</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> urllib</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">buildUrls</span><span class="params" style="color: rgb(255, 197, 143);">(word)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    word = urllib.parse.quote(word)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    url = <span class="string" style="color: rgb(209, 241, 169);">r&quot;http://image.baidu.com/search/acjson?tn=resultjson_com&amp;ipn=rj&amp;ct=201326592&amp;fp=result&amp;queryWord={word}&amp;cl=2&amp;lm=-1&amp;ie=utf-8&amp;oe=utf-8&amp;st=-1&amp;ic=0&amp;word={word}&amp;face=0&amp;istype=2nc=1&amp;pn={pn}&amp;rn=60&quot;</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    urls = (url.format(word=word, pn=x) <span class="keyword" style="color: rgb(235, 187, 255);">for</span> x <span class="keyword" style="color: rgb(235, 187, 255);">in</span> itertools.count(start=<span class="number" style="color: rgb(209, 241, 169);">0</span>, step=<span class="number" style="color: rgb(209, 241, 169);">60</span>))</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">return</span> urls</span><br data-filtered="filtered" /></pre></td></tr></tbody></table></figure><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">上面的代码中，itertools.count(start=0, step=60)表示一个从0开始，60为步长值的无限等差数列。<br data-filtered="filtered" />把这个数列的数字分别填入url作为pn值，就得到一个无限容量的url生成器，注意生成器必须用圆括号，如果写成中括号就成了列表，程序会在这一步无限执行下去。</p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">下面开始解析每次获取的数据。我们点开看看，返回的是一串json数据。<br data-filtered="filtered" /><a target=_blank target="_blank" href="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9CResponse.png" class="fancybox" rel="group" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;"><img src="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9CResponse.png" alt="接口返回数据" style="border: 1px solid rgb(221, 221, 221); display: block !important; margin: 0px auto; max-width: 100%; height: auto; cursor: -webkit-zoom-in; box-sizing: border-box; padding: 3px;" /></a></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">纳尼，这个objURL怎么不是HTTP开头的。试了几种方法都没成功，Google一下，找到这个：<a target=_blank target="_blank" href="http://blog.csdn.net/hbuxiaoshe/article/details/44780653" rel="external" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;">百度图片url解码</a></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">OK，既然明白了原理，我们写一个Python版的解密实现：<br data-filtered="filtered" /></p><figure class="highlight python" style="margin: 20px 0px; overflow: auto; padding: 15px; font-size: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; text-align: justify;"><table style="border-collapse: collapse; border-spacing: 0px; margin: 0px; width: auto; border: none; font-size: 14px; table-layout: fixed;"><tbody><tr style="background-color: rgb(249, 249, 249);"><td class="gutter" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px 20px 1px 1px; color: rgb(102, 102, 102); background: rgb(0, 36, 81); line-height: 1.6; border: none; text-align: right;"><span class="line" style="height: 20px;">1</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">2</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">3</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">4</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">5</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">6</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">7</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">8</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">9</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">10</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">11</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">12</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">13</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">14</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">15</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">16</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">17</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">18</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">19</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">20</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">21</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">22</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">23</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">24</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">25</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">26</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">27</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">28</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">29</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">30</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">31</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">32</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">33</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">34</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">35</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">36</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">37</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">38</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">39</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">40</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">41</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">42</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">43</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">44</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">45</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">46</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">47</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">48</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">49</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">50</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">51</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">52</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">53</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">54</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">55</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">56</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">57</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">58</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">59</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">60</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">61</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">62</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">63</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">64</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">65</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">66</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">67</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">68</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">69</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">70</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">71</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">72</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">73</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">74</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">75</span><br data-filtered="filtered" /></pre></td><td class="code" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; border: none;"><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);">#!/usr/bin/env python</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># -*- coding: utf-8 -*-</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># @Author: loveNight</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># @Date:   2015-11-14 21:11:11</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="string" style="color: rgb(209, 241, 169);">&quot;&quot;&quot;解码百度图片搜索json中传递的url</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">抓包可以获取加载更多图片时，服务器向网址传输的json。</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">其中originURL是特殊的字符串</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">解码前：</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">ippr_z2C$qAzdH3FAzdH3Ffl_z&amp;e3Bftgwt42_z&amp;e3BvgAzdH3F4omlaAzdH3Faa8W3ZyEpymRmx3Y1p7bb&amp;mla</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">解码后：</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">http://s9.sinaimg.cn/mw690/001WjZyEty6R6xjYdtu88&amp;690</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">使用下面两张映射表进行解码。</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">&quot;&quot;&quot;</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">str_table = {</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'_z2C$q'</span>: <span class="string" style="color: rgb(209, 241, 169);">':'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'_z&amp;e3B'</span>: <span class="string" style="color: rgb(209, 241, 169);">'.'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'AzdH3F'</span>: <span class="string" style="color: rgb(209, 241, 169);">'/'</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">}</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">char_table = {</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'w'</span>: <span class="string" style="color: rgb(209, 241, 169);">'a'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'k'</span>: <span class="string" style="color: rgb(209, 241, 169);">'b'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'v'</span>: <span class="string" style="color: rgb(209, 241, 169);">'c'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'1'</span>: <span class="string" style="color: rgb(209, 241, 169);">'d'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'j'</span>: <span class="string" style="color: rgb(209, 241, 169);">'e'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'u'</span>: <span class="string" style="color: rgb(209, 241, 169);">'f'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'2'</span>: <span class="string" style="color: rgb(209, 241, 169);">'g'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'i'</span>: <span class="string" style="color: rgb(209, 241, 169);">'h'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'t'</span>: <span class="string" style="color: rgb(209, 241, 169);">'i'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'3'</span>: <span class="string" style="color: rgb(209, 241, 169);">'j'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'h'</span>: <span class="string" style="color: rgb(209, 241, 169);">'k'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'s'</span>: <span class="string" style="color: rgb(209, 241, 169);">'l'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'4'</span>: <span class="string" style="color: rgb(209, 241, 169);">'m'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'g'</span>: <span class="string" style="color: rgb(209, 241, 169);">'n'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'5'</span>: <span class="string" style="color: rgb(209, 241, 169);">'o'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'r'</span>: <span class="string" style="color: rgb(209, 241, 169);">'p'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'q'</span>: <span class="string" style="color: rgb(209, 241, 169);">'q'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'6'</span>: <span class="string" style="color: rgb(209, 241, 169);">'r'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'f'</span>: <span class="string" style="color: rgb(209, 241, 169);">'s'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'p'</span>: <span class="string" style="color: rgb(209, 241, 169);">'t'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'7'</span>: <span class="string" style="color: rgb(209, 241, 169);">'u'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'e'</span>: <span class="string" style="color: rgb(209, 241, 169);">'v'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'o'</span>: <span class="string" style="color: rgb(209, 241, 169);">'w'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'8'</span>: <span class="string" style="color: rgb(209, 241, 169);">'1'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'d'</span>: <span class="string" style="color: rgb(209, 241, 169);">'2'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'n'</span>: <span class="string" style="color: rgb(209, 241, 169);">'3'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'9'</span>: <span class="string" style="color: rgb(209, 241, 169);">'4'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'c'</span>: <span class="string" style="color: rgb(209, 241, 169);">'5'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'m'</span>: <span class="string" style="color: rgb(209, 241, 169);">'6'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'0'</span>: <span class="string" style="color: rgb(209, 241, 169);">'7'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'b'</span>: <span class="string" style="color: rgb(209, 241, 169);">'8'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'l'</span>: <span class="string" style="color: rgb(209, 241, 169);">'9'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'a'</span>: <span class="string" style="color: rgb(209, 241, 169);">'0'</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">}</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># str 的translate方法需要用单个字符的十进制unicode编码作为key</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># value 中的数字会被当成十进制unicode编码转换成字符</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># 也可以直接用字符串作为value</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">char_table = {ord(key): ord(value) <span class="keyword" style="color: rgb(235, 187, 255);">for</span> key, value <span class="keyword" style="color: rgb(235, 187, 255);">in</span> char_table.items()}</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">decode</span><span class="params" style="color: rgb(255, 197, 143);">(url)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="comment" style="color: rgb(114, 133, 183);"># 先替换字符串</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">for</span> key, value <span class="keyword" style="color: rgb(235, 187, 255);">in</span> str_table.items():</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        url = url.replace(key, value)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="comment" style="color: rgb(114, 133, 183);"># 再替换剩下的字符</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">return</span> url.translate(char_table)</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">if</span> __name__ == <span class="string" style="color: rgb(209, 241, 169);">'__main__'</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    url = <span class="string" style="color: rgb(209, 241, 169);">r&quot;ippr_z2C$qAzdH3FAzdH3Ffl_z&amp;e3Bftgwt42_z&amp;e3BvgAzdH3F4omlaAzdH3Faa8W3ZyEpymRmx3Y1p7bb&amp;mla&quot;</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    print(decode(url))</span><br data-filtered="filtered" /></pre></td></tr></tbody></table></figure><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">测试成功！</p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">再从JSON字符串中找出所有的originURL：<br data-filtered="filtered" /></p><figure class="highlight python" style="margin: 20px 0px; overflow: auto; padding: 15px; font-size: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; text-align: justify;"><table style="border-collapse: collapse; border-spacing: 0px; margin: 0px; width: auto; border: none; font-size: 14px; table-layout: fixed;"><tbody><tr style="background-color: rgb(249, 249, 249);"><td class="gutter" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px 20px 1px 1px; color: rgb(102, 102, 102); background: rgb(0, 36, 81); line-height: 1.6; border: none; text-align: right;"><span class="line" style="height: 20px;">1</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">2</span><br data-filtered="filtered" /></pre></td><td class="code" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; border: none;"><span class="line" style="height: 20px;">re_url = re.compile(<span class="string" style="color: rgb(209, 241, 169);">r'&quot;objURL&quot;:&quot;(.*?)&quot;'</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">imgs = re_url.findall(html)</span><br data-filtered="filtered" /></pre></td></tr></tbody></table></figure><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">格式化JSON推荐使用Chrome的<a target=_blank target="_blank" href="https://chrome.google.com/webstore/detail/iahnhfdhidomcpggpaimmmahffihkfnj" rel="external" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;">JSON handle插件</a><br data-filtered="filtered" /><a target=_blank target="_blank" href="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9CJSON%20Handle.png" class="fancybox" rel="group" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;"><img src="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9CJSON%20Handle.png" alt="JSON hanlde插件效果" style="border: 1px solid rgb(221, 221, 221); display: block !important; margin: 0px auto; max-width: 100%; height: auto; cursor: -webkit-zoom-in; box-sizing: border-box; padding: 3px;" /></a></p><h2 id="单线程下载脚本" style="margin: 20px 0px 15px; padding: 10px 0px 0px; line-height: 1.5; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 20px; color: rgb(85, 85, 85); text-align: justify;">单线程下载脚本</h2><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">整理一下流程：</p><ol style="color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"><li>生成网址列表</li><li>发送HTTP请求获取json数据</li><li>解析数据得到网址</li><li>下载</li></ol><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">整合一下上面的代码，可以写出单线程的下载脚本：<br data-filtered="filtered" /></p><figure class="highlight python" style="margin: 20px 0px; overflow: auto; padding: 15px; font-size: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; text-align: justify;"><table style="border-collapse: collapse; border-spacing: 0px; margin: 0px; width: auto; border: none; font-size: 14px; table-layout: fixed;"><tbody><tr style="background-color: rgb(249, 249, 249);"><td class="gutter" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px 20px 1px 1px; color: rgb(102, 102, 102); background: rgb(0, 36, 81); line-height: 1.6; border: none; text-align: right;"><span class="line" style="height: 20px;">1</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">2</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">3</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">4</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">5</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">6</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">7</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">8</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">9</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">10</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">11</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">12</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">13</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">14</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">15</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">16</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">17</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">18</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">19</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">20</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">21</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">22</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">23</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">24</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">25</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">26</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">27</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">28</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">29</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">30</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">31</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">32</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">33</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">34</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">35</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">36</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">37</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">38</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">39</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">40</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">41</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">42</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">43</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">44</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">45</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">46</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">47</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">48</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">49</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">50</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">51</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">52</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">53</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">54</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">55</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">56</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">57</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">58</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">59</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">60</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">61</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">62</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">63</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">64</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">65</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">66</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">67</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">68</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">69</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">70</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">71</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">72</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">73</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">74</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">75</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">76</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">77</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">78</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">79</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">80</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">81</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">82</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">83</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">84</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">85</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">86</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">87</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">88</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">89</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">90</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">91</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">92</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">93</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">94</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">95</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">96</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">97</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">98</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">99</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">100</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">101</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">102</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">103</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">104</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">105</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">106</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">107</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">108</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">109</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">110</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">111</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">112</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">113</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">114</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">115</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">116</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">117</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">118</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">119</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">120</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">121</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">122</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">123</span><br data-filtered="filtered" /></pre></td><td class="code" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; border: none;"><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);">#!/usr/bin/env python</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># -*- coding: utf-8 -*-</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># @Author: loveNight</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> json</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> itertools</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> urllib</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> requests</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> os</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> re</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> sys</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">str_table = {</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'_z2C$q'</span>: <span class="string" style="color: rgb(209, 241, 169);">':'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'_z&amp;e3B'</span>: <span class="string" style="color: rgb(209, 241, 169);">'.'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'AzdH3F'</span>: <span class="string" style="color: rgb(209, 241, 169);">'/'</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">}</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">char_table = {</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'w'</span>: <span class="string" style="color: rgb(209, 241, 169);">'a'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'k'</span>: <span class="string" style="color: rgb(209, 241, 169);">'b'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'v'</span>: <span class="string" style="color: rgb(209, 241, 169);">'c'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'1'</span>: <span class="string" style="color: rgb(209, 241, 169);">'d'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'j'</span>: <span class="string" style="color: rgb(209, 241, 169);">'e'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'u'</span>: <span class="string" style="color: rgb(209, 241, 169);">'f'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'2'</span>: <span class="string" style="color: rgb(209, 241, 169);">'g'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'i'</span>: <span class="string" style="color: rgb(209, 241, 169);">'h'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'t'</span>: <span class="string" style="color: rgb(209, 241, 169);">'i'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'3'</span>: <span class="string" style="color: rgb(209, 241, 169);">'j'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'h'</span>: <span class="string" style="color: rgb(209, 241, 169);">'k'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'s'</span>: <span class="string" style="color: rgb(209, 241, 169);">'l'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'4'</span>: <span class="string" style="color: rgb(209, 241, 169);">'m'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'g'</span>: <span class="string" style="color: rgb(209, 241, 169);">'n'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'5'</span>: <span class="string" style="color: rgb(209, 241, 169);">'o'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'r'</span>: <span class="string" style="color: rgb(209, 241, 169);">'p'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'q'</span>: <span class="string" style="color: rgb(209, 241, 169);">'q'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'6'</span>: <span class="string" style="color: rgb(209, 241, 169);">'r'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'f'</span>: <span class="string" style="color: rgb(209, 241, 169);">'s'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'p'</span>: <span class="string" style="color: rgb(209, 241, 169);">'t'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'7'</span>: <span class="string" style="color: rgb(209, 241, 169);">'u'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'e'</span>: <span class="string" style="color: rgb(209, 241, 169);">'v'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'o'</span>: <span class="string" style="color: rgb(209, 241, 169);">'w'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'8'</span>: <span class="string" style="color: rgb(209, 241, 169);">'1'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'d'</span>: <span class="string" style="color: rgb(209, 241, 169);">'2'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'n'</span>: <span class="string" style="color: rgb(209, 241, 169);">'3'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'9'</span>: <span class="string" style="color: rgb(209, 241, 169);">'4'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'c'</span>: <span class="string" style="color: rgb(209, 241, 169);">'5'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'m'</span>: <span class="string" style="color: rgb(209, 241, 169);">'6'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'0'</span>: <span class="string" style="color: rgb(209, 241, 169);">'7'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'b'</span>: <span class="string" style="color: rgb(209, 241, 169);">'8'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'l'</span>: <span class="string" style="color: rgb(209, 241, 169);">'9'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">'a'</span>: <span class="string" style="color: rgb(209, 241, 169);">'0'</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">}</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># str 的translate方法需要用单个字符的十进制unicode编码作为key</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># value 中的数字会被当成十进制unicode编码转换成字符</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># 也可以直接用字符串作为value</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">char_table = {ord(key): ord(value) <span class="keyword" style="color: rgb(235, 187, 255);">for</span> key, value <span class="keyword" style="color: rgb(235, 187, 255);">in</span> char_table.items()}</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># 解码图片URL</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">decode</span><span class="params" style="color: rgb(255, 197, 143);">(url)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="comment" style="color: rgb(114, 133, 183);"># 先替换字符串</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">for</span> key, value <span class="keyword" style="color: rgb(235, 187, 255);">in</span> str_table.items():</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        url = url.replace(key, value)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="comment" style="color: rgb(114, 133, 183);"># 再替换剩下的字符</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">return</span> url.translate(char_table)</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># 生成网址列表</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">buildUrls</span><span class="params" style="color: rgb(255, 197, 143);">(word)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    word = urllib.parse.quote(word)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    url = <span class="string" style="color: rgb(209, 241, 169);">r&quot;http://image.baidu.com/search/acjson?tn=resultjson_com&amp;ipn=rj&amp;ct=201326592&amp;fp=result&amp;queryWord={word}&amp;cl=2&amp;lm=-1&amp;ie=utf-8&amp;oe=utf-8&amp;st=-1&amp;ic=0&amp;word={word}&amp;face=0&amp;istype=2nc=1&amp;pn={pn}&amp;rn=60&quot;</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    urls = (url.format(word=word, pn=x) <span class="keyword" style="color: rgb(235, 187, 255);">for</span> x <span class="keyword" style="color: rgb(235, 187, 255);">in</span> itertools.count(start=<span class="number" style="color: rgb(209, 241, 169);">0</span>, step=<span class="number" style="color: rgb(209, 241, 169);">60</span>))</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">return</span> urls</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># 解析JSON获取图片URL</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">re_url = re.compile(<span class="string" style="color: rgb(209, 241, 169);">r'&quot;objURL&quot;:&quot;(.*?)&quot;'</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">resolveImgUrl</span><span class="params" style="color: rgb(255, 197, 143);">(html)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    imgUrls = [decode(x) <span class="keyword" style="color: rgb(235, 187, 255);">for</span> x <span class="keyword" style="color: rgb(235, 187, 255);">in</span> re_url.findall(html)]</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">return</span> imgUrls</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">downImg</span><span class="params" style="color: rgb(255, 197, 143);">(imgUrl, dirpath, imgName)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    filename = os.path.join(dirpath, imgName)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">try</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        res = requests.get(imgUrl, timeout=<span class="number" style="color: rgb(209, 241, 169);">15</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">if</span> str(res.status_code)[<span class="number" style="color: rgb(209, 241, 169);">0</span>] == <span class="string" style="color: rgb(209, 241, 169);">&quot;4&quot;</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            print(str(res.status_code), <span class="string" style="color: rgb(209, 241, 169);">&quot;:&quot;</span> , imgUrl)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">return</span> <span class="keyword" style="color: rgb(235, 187, 255);">False</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">except</span> Exception <span class="keyword" style="color: rgb(235, 187, 255);">as</span> e:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        print(<span class="string" style="color: rgb(209, 241, 169);">&quot;抛出异常：&quot;</span>, imgUrl)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        print(e)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">return</span> <span class="keyword" style="color: rgb(235, 187, 255);">False</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">with</span> open(filename, <span class="string" style="color: rgb(209, 241, 169);">&quot;wb&quot;</span>) <span class="keyword" style="color: rgb(235, 187, 255);">as</span> f:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        f.write(res.content)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">return</span> <span class="keyword" style="color: rgb(235, 187, 255);">True</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">mkDir</span><span class="params" style="color: rgb(255, 197, 143);">(dirName)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    dirpath = os.path.join(sys.path[<span class="number" style="color: rgb(209, 241, 169);">0</span>], dirName)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">if</span> <span class="keyword" style="color: rgb(235, 187, 255);">not</span> os.path.exists(dirpath):</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        os.mkdir(dirpath)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">return</span> dirpath</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">if</span> __name__ == <span class="string" style="color: rgb(209, 241, 169);">'__main__'</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    print(<span class="string" style="color: rgb(209, 241, 169);">&quot;欢迎使用百度图片下载脚本！\n目前仅支持单个关键词。&quot;</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    print(<span class="string" style="color: rgb(209, 241, 169);">&quot;下载结果保存在脚本目录下的results文件夹中。&quot;</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    print(<span class="string" style="color: rgb(209, 241, 169);">&quot;=&quot;</span> * <span class="number" style="color: rgb(209, 241, 169);">50</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    word = input(<span class="string" style="color: rgb(209, 241, 169);">&quot;请输入你要下载的图片关键词：\n&quot;</span>)</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    dirpath = mkDir(<span class="string" style="color: rgb(209, 241, 169);">&quot;results&quot;</span>)</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    urls = buildUrls(word)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    index = <span class="number" style="color: rgb(209, 241, 169);">0</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="keyword" style="color: rgb(235, 187, 255);">for</span> url <span class="keyword" style="color: rgb(235, 187, 255);">in</span> urls:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        print(<span class="string" style="color: rgb(209, 241, 169);">&quot;正在请求：&quot;</span>, url)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        html = requests.get(url, timeout=<span class="number" style="color: rgb(209, 241, 169);">10</span>).content.decode(<span class="string" style="color: rgb(209, 241, 169);">'utf-8'</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        imgUrls = resolveImgUrl(html)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">if</span> len(imgUrls) == <span class="number" style="color: rgb(209, 241, 169);">0</span>:  <span class="comment" style="color: rgb(114, 133, 183);"># 没有图片则结束</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">break</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">for</span> url <span class="keyword" style="color: rgb(235, 187, 255);">in</span> imgUrls:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">if</span> downImg(url, dirpath, str(index) + <span class="string" style="color: rgb(209, 241, 169);">&quot;.jpg&quot;</span>):</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                index += <span class="number" style="color: rgb(209, 241, 169);">1</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                print(<span class="string" style="color: rgb(209, 241, 169);">&quot;已下载 %s 张&quot;</span> % index)</span><br data-filtered="filtered" /></pre></td></tr></tbody></table></figure><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">执行脚本：<br data-filtered="filtered" /><a target=_blank target="_blank" href="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C%E5%8D%95%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%BB%93%E6%9E%9C.png" class="fancybox" rel="group" style="background-color: transparent; color: rgb(5, 147, 211); text-decoration: none; border-bottom: 1px solid rgb(153, 153, 153); word-wrap: break-word;"><img src="http://7xo8t2.com1.z0.glb.clouddn.com/img/%E7%BC%96%E7%A8%8B/Python/Python%203%20%E5%A4%9A%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%99%BE%E5%BA%A6%E5%9B%BE%E7%89%87%E6%90%9C%E7%B4%A2%E7%BB%93%E6%9E%9C%E5%8D%95%E7%BA%BF%E7%A8%8B%E4%B8%8B%E8%BD%BD%E7%BB%93%E6%9E%9C.png" alt="单线程下载结果" style="border: 1px solid rgb(221, 221, 221); display: block !important; margin: 0px auto; max-width: 100%; height: auto; cursor: -webkit-zoom-in; box-sizing: border-box; padding: 3px;" /></a></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">查看同目录下的results文件夹，又看到了亲切的「他」。</p><h2 id="多线程下载脚本" style="margin: 20px 0px 15px; padding: 10px 0px 0px; line-height: 1.5; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 20px; color: rgb(85, 85, 85); text-align: justify;">多线程下载脚本</h2><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">上面的代码仍然有改进空间：</p><ol style="color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"><li>从JSON数据看，该关键词相关的图片有一千多张，单线程下载太慢了，时间都花在网络和硬盘IO上。加上多线程可以大大提升效率。</li><li>既然1中已经获取到图片总数，那么网址的无限容量生成器可以改成list，方便添加多线程。</li></ol><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">多线程一直没学好，想不到更优雅的写法，大家将就看一下吧，欢迎提出改进建议。</p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">百度图片下载脚本之多线程版：<br data-filtered="filtered" /></p><figure class="highlight python" style="margin: 20px 0px; overflow: auto; padding: 15px; font-size: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; text-align: justify;"><table style="border-collapse: collapse; border-spacing: 0px; margin: 0px; width: auto; border: none; font-size: 14px; table-layout: fixed;"><tbody><tr style="background-color: rgb(249, 249, 249);"><td class="gutter" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px 20px 1px 1px; color: rgb(102, 102, 102); background: rgb(0, 36, 81); line-height: 1.6; border: none; text-align: right;"><span class="line" style="height: 20px;">1</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">2</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">3</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">4</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">5</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">6</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">7</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">8</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">9</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">10</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">11</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">12</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">13</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">14</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">15</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">16</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">17</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">18</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">19</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">20</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">21</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">22</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">23</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">24</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">25</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">26</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">27</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">28</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">29</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">30</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">31</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">32</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">33</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">34</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">35</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">36</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">37</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">38</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">39</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">40</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">41</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">42</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">43</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">44</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">45</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">46</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">47</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">48</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">49</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">50</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">51</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">52</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">53</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">54</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">55</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">56</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">57</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">58</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">59</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">60</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">61</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">62</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">63</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">64</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">65</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">66</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">67</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">68</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">69</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">70</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">71</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">72</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">73</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">74</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">75</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">76</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">77</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">78</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">79</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">80</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">81</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">82</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">83</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">84</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">85</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">86</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">87</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">88</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">89</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">90</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">91</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">92</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">93</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">94</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">95</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">96</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">97</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">98</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">99</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">100</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">101</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">102</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">103</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">104</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">105</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">106</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">107</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">108</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">109</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">110</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">111</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">112</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">113</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">114</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">115</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">116</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">117</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">118</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">119</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">120</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">121</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">122</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">123</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">124</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">125</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">126</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">127</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">128</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">129</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">130</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">131</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">132</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">133</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">134</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">135</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">136</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">137</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">138</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">139</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">140</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">141</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">142</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">143</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">144</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">145</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">146</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">147</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">148</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">149</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">150</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">151</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">152</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">153</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">154</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">155</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">156</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">157</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">158</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">159</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">160</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">161</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">162</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">163</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">164</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">165</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">166</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">167</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">168</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">169</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">170</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">171</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">172</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">173</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">174</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">175</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">176</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">177</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">178</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">179</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">180</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">181</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">182</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">183</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">184</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">185</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">186</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">187</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">188</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">189</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">190</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">191</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">192</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">193</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">194</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">195</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">196</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">197</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">198</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">199</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">200</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">201</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">202</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">203</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">204</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">205</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">206</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">207</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">208</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">209</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">210</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">211</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">212</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">213</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">214</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">215</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">216</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">217</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">218</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">219</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">220</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">221</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">222</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">223</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">224</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">225</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">226</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">227</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">228</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">229</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">230</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">231</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">232</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">233</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">234</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">235</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">236</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">237</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">238</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">239</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">240</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">241</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">242</span><br data-filtered="filtered" /></pre></td><td class="code" style="padding: 0px; vertical-align: middle; border: none;"><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 0px; margin-bottom: 0px; padding: 1px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; border: none;"><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);">#!/usr/bin/env python</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># -*- coding: utf-8 -*-</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># @Author: loveNight</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># @Date:   2015-10-28 19:59:24</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># @Last Modified by:   loveNight</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="comment" style="color: rgb(114, 133, 183);"># @Last Modified time: 2015-11-15 19:24:57</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> urllib</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> requests</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> os</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> re</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> sys</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> time</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">import</span> threading</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">from</span> datetime <span class="keyword" style="color: rgb(235, 187, 255);">import</span> datetime <span class="keyword" style="color: rgb(235, 187, 255);">as</span> dt</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">from</span> multiprocessing.dummy <span class="keyword" style="color: rgb(235, 187, 255);">import</span> Pool</span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">from</span> multiprocessing <span class="keyword" style="color: rgb(235, 187, 255);">import</span> Queue</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="class"><span class="keyword" style="color: rgb(235, 187, 255);">class</span> <span class="title" style="color: rgb(153, 255, 255);">BaiduImgDownloader</span><span class="params" style="color: rgb(255, 197, 143);">(object)</span>:</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">&quot;&quot;&quot;百度图片下载工具，目前只支持单个关键词&quot;&quot;&quot;</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="comment" style="color: rgb(114, 133, 183);"># 解码网址用的映射表</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    str_table = {</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'_z2C$q'</span>: <span class="string" style="color: rgb(209, 241, 169);">':'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'_z&amp;e3B'</span>: <span class="string" style="color: rgb(209, 241, 169);">'.'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'AzdH3F'</span>: <span class="string" style="color: rgb(209, 241, 169);">'/'</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    }</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    char_table = {</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'w'</span>: <span class="string" style="color: rgb(209, 241, 169);">'a'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'k'</span>: <span class="string" style="color: rgb(209, 241, 169);">'b'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'v'</span>: <span class="string" style="color: rgb(209, 241, 169);">'c'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'1'</span>: <span class="string" style="color: rgb(209, 241, 169);">'d'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'j'</span>: <span class="string" style="color: rgb(209, 241, 169);">'e'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'u'</span>: <span class="string" style="color: rgb(209, 241, 169);">'f'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'2'</span>: <span class="string" style="color: rgb(209, 241, 169);">'g'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'i'</span>: <span class="string" style="color: rgb(209, 241, 169);">'h'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'t'</span>: <span class="string" style="color: rgb(209, 241, 169);">'i'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'3'</span>: <span class="string" style="color: rgb(209, 241, 169);">'j'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'h'</span>: <span class="string" style="color: rgb(209, 241, 169);">'k'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'s'</span>: <span class="string" style="color: rgb(209, 241, 169);">'l'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'4'</span>: <span class="string" style="color: rgb(209, 241, 169);">'m'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'g'</span>: <span class="string" style="color: rgb(209, 241, 169);">'n'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'5'</span>: <span class="string" style="color: rgb(209, 241, 169);">'o'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'r'</span>: <span class="string" style="color: rgb(209, 241, 169);">'p'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'q'</span>: <span class="string" style="color: rgb(209, 241, 169);">'q'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'6'</span>: <span class="string" style="color: rgb(209, 241, 169);">'r'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'f'</span>: <span class="string" style="color: rgb(209, 241, 169);">'s'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'p'</span>: <span class="string" style="color: rgb(209, 241, 169);">'t'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'7'</span>: <span class="string" style="color: rgb(209, 241, 169);">'u'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'e'</span>: <span class="string" style="color: rgb(209, 241, 169);">'v'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'o'</span>: <span class="string" style="color: rgb(209, 241, 169);">'w'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'8'</span>: <span class="string" style="color: rgb(209, 241, 169);">'1'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'d'</span>: <span class="string" style="color: rgb(209, 241, 169);">'2'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'n'</span>: <span class="string" style="color: rgb(209, 241, 169);">'3'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'9'</span>: <span class="string" style="color: rgb(209, 241, 169);">'4'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'c'</span>: <span class="string" style="color: rgb(209, 241, 169);">'5'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'m'</span>: <span class="string" style="color: rgb(209, 241, 169);">'6'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'0'</span>: <span class="string" style="color: rgb(209, 241, 169);">'7'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'b'</span>: <span class="string" style="color: rgb(209, 241, 169);">'8'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'l'</span>: <span class="string" style="color: rgb(209, 241, 169);">'9'</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">'a'</span>: <span class="string" style="color: rgb(209, 241, 169);">'0'</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    }</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    re_objURL = re.compile(<span class="string" style="color: rgb(209, 241, 169);">r'&quot;objURL&quot;:&quot;(.*?)&quot;.*?&quot;type&quot;:&quot;(.*?)&quot;'</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    re_downNum = re.compile(<span class="string" style="color: rgb(209, 241, 169);">r&quot;已下载\s(\d+)\s张图片&quot;</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    headers = {</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">&quot;User-Agent&quot;</span>: <span class="string" style="color: rgb(209, 241, 169);">&quot;Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36&quot;</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">&quot;Accept-Encoding&quot;</span>: <span class="string" style="color: rgb(209, 241, 169);">&quot;gzip, deflate, sdch&quot;</span>,</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    }</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">__init__</span><span class="params" style="color: rgb(255, 197, 143);">(self, word, dirpath=None, processNum=<span class="number" style="color: rgb(209, 241, 169);">30</span>)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">if</span> <span class="string" style="color: rgb(209, 241, 169);">&quot; &quot;</span> <span class="keyword" style="color: rgb(235, 187, 255);">in</span> word:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">raise</span> AttributeError(<span class="string" style="color: rgb(209, 241, 169);">&quot;本脚本仅支持单个关键字&quot;</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.word = word</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.char_table = {ord(key): ord(value)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                           <span class="keyword" style="color: rgb(235, 187, 255);">for</span> key, value <span class="keyword" style="color: rgb(235, 187, 255);">in</span> BaiduImgDownloader.char_table.items()}</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">if</span> <span class="keyword" style="color: rgb(235, 187, 255);">not</span> dirpath:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            dirpath = os.path.join(sys.path[<span class="number" style="color: rgb(209, 241, 169);">0</span>], <span class="string" style="color: rgb(209, 241, 169);">'results'</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.dirpath = dirpath</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.jsonUrlFile = os.path.join(sys.path[<span class="number" style="color: rgb(209, 241, 169);">0</span>], <span class="string" style="color: rgb(209, 241, 169);">'jsonUrl.txt'</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.logFile = os.path.join(sys.path[<span class="number" style="color: rgb(209, 241, 169);">0</span>], <span class="string" style="color: rgb(209, 241, 169);">'logInfo.txt'</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.errorFile = os.path.join(sys.path[<span class="number" style="color: rgb(209, 241, 169);">0</span>], <span class="string" style="color: rgb(209, 241, 169);">'errorUrl.txt'</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">if</span> os.path.exists(self.errorFile):</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            os.remove(self.errorFile)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">if</span> <span class="keyword" style="color: rgb(235, 187, 255);">not</span> os.path.exists(self.dirpath):</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            os.mkdir(self.dirpath)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.pool = Pool(<span class="number" style="color: rgb(209, 241, 169);">30</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.session = requests.Session()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.session.headers = BaiduImgDownloader.headers</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.queue = Queue()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.messageQueue = Queue()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.index = <span class="number" style="color: rgb(209, 241, 169);">0</span> <span class="comment" style="color: rgb(114, 133, 183);"># 图片起始编号，牵涉到计数，不要更改</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.promptNum = <span class="number" style="color: rgb(209, 241, 169);">10</span> <span class="comment" style="color: rgb(114, 133, 183);"># 下载几张图片提示一次</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.lock = threading.Lock()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.delay = <span class="number" style="color: rgb(209, 241, 169);">1.5</span>  <span class="comment" style="color: rgb(114, 133, 183);"># 网络请求太频繁会被封</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.QUIT = <span class="string" style="color: rgb(209, 241, 169);">&quot;QUIT&quot;</span>  <span class="comment" style="color: rgb(114, 133, 183);"># Queue中表示任务结束</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.printPrefix = <span class="string" style="color: rgb(209, 241, 169);">&quot;**&quot;</span> <span class="comment" style="color: rgb(114, 133, 183);"># 用于指定在控制台输出</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">start</span><span class="params" style="color: rgb(255, 197, 143);">(self)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="comment" style="color: rgb(114, 133, 183);"># 控制台输出线程</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        t = threading.Thread(target=self.__log)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        t.setDaemon(<span class="keyword" style="color: rgb(235, 187, 255);">True</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        t.start()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.messageQueue.put(self.printPrefix + <span class="string" style="color: rgb(209, 241, 169);">&quot;脚本开始执行&quot;</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        start_time = dt.now()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        urls = self.__buildUrls()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.messageQueue.put(self.printPrefix + <span class="string" style="color: rgb(209, 241, 169);">&quot;已获取 %s 个Json请求网址&quot;</span> % len(urls))</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="comment" style="color: rgb(114, 133, 183);"># 解析出所有图片网址，该方法会阻塞直到任务完成</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.pool.map(self.__resolveImgUrl, urls)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">while</span> self.queue.qsize():</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            imgs = self.queue.get()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            self.pool.map_async(self.__downImg, imgs)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.pool.close()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.pool.join()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.messageQueue.put(self.printPrefix + <span class="string" style="color: rgb(209, 241, 169);">&quot;下载完成！已下载 %s 张图片，总用时 %s&quot;</span> %</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                              (self.index, dt.now() - start_time))</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.messageQueue.put(self.printPrefix + <span class="string" style="color: rgb(209, 241, 169);">&quot;请到 %s 查看结果！&quot;</span> % self.dirpath)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.messageQueue.put(self.printPrefix + <span class="string" style="color: rgb(209, 241, 169);">&quot;错误信息保存在 %s&quot;</span> % self.errorFile)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.messageQueue.put(self.QUIT)</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">__log</span><span class="params" style="color: rgb(255, 197, 143);">(self)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">&quot;&quot;&quot;控制台输出，加锁以免被多线程打乱&quot;&quot;&quot;</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">with</span> open(self.logFile, <span class="string" style="color: rgb(209, 241, 169);">&quot;w&quot;</span>, encoding = <span class="string" style="color: rgb(209, 241, 169);">&quot;utf-8&quot;</span>) <span class="keyword" style="color: rgb(235, 187, 255);">as</span> f:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">while</span> <span class="keyword" style="color: rgb(235, 187, 255);">True</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                message = self.messageQueue.get()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                <span class="keyword" style="color: rgb(235, 187, 255);">if</span> message == self.QUIT:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                    <span class="keyword" style="color: rgb(235, 187, 255);">break</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                message = str(dt.now()) + <span class="string" style="color: rgb(209, 241, 169);">&quot; &quot;</span> + message</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                <span class="keyword" style="color: rgb(235, 187, 255);">if</span> self.printPrefix  <span class="keyword" style="color: rgb(235, 187, 255);">in</span> message:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                    print(message)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                <span class="keyword" style="color: rgb(235, 187, 255);">elif</span> <span class="string" style="color: rgb(209, 241, 169);">&quot;已下载&quot;</span> <span class="keyword" style="color: rgb(235, 187, 255);">in</span> message:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                    <span class="comment" style="color: rgb(114, 133, 183);"># 下载N张图片提示一次</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                    downNum = self.re_downNum.findall(message)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                    <span class="keyword" style="color: rgb(235, 187, 255);">if</span> downNum <span class="keyword" style="color: rgb(235, 187, 255);">and</span> int(downNum[<span class="number" style="color: rgb(209, 241, 169);">0</span>]) % self.promptNum == <span class="number" style="color: rgb(209, 241, 169);">0</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                        print(message)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                f.write(message + <span class="string" style="color: rgb(209, 241, 169);">'\n'</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                f.flush()</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">__getIndex</span><span class="params" style="color: rgb(255, 197, 143);">(self)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">&quot;&quot;&quot;获取文件编号&quot;&quot;&quot;</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.lock.acquire()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">try</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">return</span> self.index</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">finally</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            self.index += <span class="number" style="color: rgb(209, 241, 169);">1</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            self.lock.release()</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">decode</span><span class="params" style="color: rgb(255, 197, 143);">(self, url)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">&quot;&quot;&quot;解码图片URL</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        解码前：</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        ippr_z2C$qAzdH3FAzdH3Ffl_z&amp;e3Bftgwt42_z&amp;e3BvgAzdH3F4omlaAzdH3Faa8W3ZyEpymRmx3Y1p7bb&amp;mla</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        解码后：</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        http://s9.sinaimg.cn/mw690/001WjZyEty6R6xjYdtu88&amp;690</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        &quot;&quot;&quot;</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="comment" style="color: rgb(114, 133, 183);"># 先替换字符串</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">for</span> key, value <span class="keyword" style="color: rgb(235, 187, 255);">in</span> self.str_table.items():</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            url = url.replace(key, value)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="comment" style="color: rgb(114, 133, 183);"># 再替换剩下的字符</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">return</span> url.translate(self.char_table)</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">__buildUrls</span><span class="params" style="color: rgb(255, 197, 143);">(self)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">&quot;&quot;&quot;json请求网址生成器&quot;&quot;&quot;</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        word = urllib.parse.quote(self.word)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        url = <span class="string" style="color: rgb(209, 241, 169);">r&quot;http://image.baidu.com/search/acjson?tn=resultjson_com&amp;ipn=rj&amp;ct=201326592&amp;fp=result&amp;queryWord={word}&amp;cl=2&amp;lm=-1&amp;ie=utf-8&amp;oe=utf-8&amp;st=-1&amp;ic=0&amp;word={word}&amp;face=0&amp;istype=2nc=1&amp;pn={pn}&amp;rn=60&quot;</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        time.sleep(self.delay)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        html = self.session.get(url.format(word=word, pn=<span class="number" style="color: rgb(209, 241, 169);">0</span>), timeout = <span class="number" style="color: rgb(209, 241, 169);">15</span>).content.decode(<span class="string" style="color: rgb(209, 241, 169);">'utf-8'</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        results = re.findall(<span class="string" style="color: rgb(209, 241, 169);">r'&quot;displayNum&quot;:(\d+),'</span>, html)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        maxNum = int(results[<span class="number" style="color: rgb(209, 241, 169);">0</span>]) <span class="keyword" style="color: rgb(235, 187, 255);">if</span> results <span class="keyword" style="color: rgb(235, 187, 255);">else</span> <span class="number" style="color: rgb(209, 241, 169);">0</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        urls = [url.format(word=word, pn=x)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                <span class="keyword" style="color: rgb(235, 187, 255);">for</span> x <span class="keyword" style="color: rgb(235, 187, 255);">in</span> range(<span class="number" style="color: rgb(209, 241, 169);">0</span>, maxNum + <span class="number" style="color: rgb(209, 241, 169);">1</span>, <span class="number" style="color: rgb(209, 241, 169);">60</span>)]</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">with</span> open(self.jsonUrlFile, <span class="string" style="color: rgb(209, 241, 169);">&quot;w&quot;</span>, encoding=<span class="string" style="color: rgb(209, 241, 169);">&quot;utf-8&quot;</span>) <span class="keyword" style="color: rgb(235, 187, 255);">as</span> f:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">for</span> url <span class="keyword" style="color: rgb(235, 187, 255);">in</span> urls:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                f.write(url + <span class="string" style="color: rgb(209, 241, 169);">&quot;\n&quot;</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">return</span> urls</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">__resolveImgUrl</span><span class="params" style="color: rgb(255, 197, 143);">(self, url)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">&quot;&quot;&quot;从指定网页中解析出图片URL&quot;&quot;&quot;</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        time.sleep(self.delay)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        html = self.session.get(url, timeout = <span class="number" style="color: rgb(209, 241, 169);">15</span>).content.decode(<span class="string" style="color: rgb(209, 241, 169);">'utf-8'</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        datas = self.re_objURL.findall(html)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        imgs = [Image(self.decode(x[<span class="number" style="color: rgb(209, 241, 169);">0</span>]), x[<span class="number" style="color: rgb(209, 241, 169);">1</span>]) <span class="keyword" style="color: rgb(235, 187, 255);">for</span> x <span class="keyword" style="color: rgb(235, 187, 255);">in</span> datas]</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.messageQueue.put(self.printPrefix + <span class="string" style="color: rgb(209, 241, 169);">&quot;已解析出 %s 个图片网址&quot;</span> % len(imgs))</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.queue.put(imgs)</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">__downImg</span><span class="params" style="color: rgb(255, 197, 143);">(self, img)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="string" style="color: rgb(209, 241, 169);">&quot;&quot;&quot;下载单张图片，传入的是Image对象&quot;&quot;&quot;</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        imgUrl = img.url</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="comment" style="color: rgb(114, 133, 183);"># self.messageQueue.put(&quot;线程 %s 正在下载 %s &quot; %</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="comment" style="color: rgb(114, 133, 183);">#          (threading.current_thread().name, imgUrl))</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">try</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            time.sleep(self.delay)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            res = self.session.get(imgUrl, timeout = <span class="number" style="color: rgb(209, 241, 169);">15</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            message = <span class="keyword" style="color: rgb(235, 187, 255);">None</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">if</span> str(res.status_code)[<span class="number" style="color: rgb(209, 241, 169);">0</span>] == <span class="string" style="color: rgb(209, 241, 169);">&quot;4&quot;</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                message = <span class="string" style="color: rgb(209, 241, 169);">&quot;\n%s： %s&quot;</span> % (res.status_code, imgUrl)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">elif</span> <span class="string" style="color: rgb(209, 241, 169);">&quot;text/html&quot;</span> <span class="keyword" style="color: rgb(235, 187, 255);">in</span> res.headers[<span class="string" style="color: rgb(209, 241, 169);">&quot;Content-Type&quot;</span>]:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                message = <span class="string" style="color: rgb(209, 241, 169);">&quot;\n无法打开图片： %s&quot;</span> % imgUrl</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">except</span> Exception <span class="keyword" style="color: rgb(235, 187, 255);">as</span> e:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            message = <span class="string" style="color: rgb(209, 241, 169);">&quot;\n抛出异常： %s\n%s&quot;</span> % (imgUrl, str(e))</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">finally</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">if</span> message:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                self.messageQueue.put(message)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                self.__saveError(message)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                <span class="keyword" style="color: rgb(235, 187, 255);">return</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        index = self.__getIndex()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="comment" style="color: rgb(114, 133, 183);"># index从0开始</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.messageQueue.put(<span class="string" style="color: rgb(209, 241, 169);">&quot;已下载 %s 张图片：%s&quot;</span> % (index + <span class="number" style="color: rgb(209, 241, 169);">1</span>, imgUrl))</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        filename = os.path.join(self.dirpath, str(index) + <span class="string" style="color: rgb(209, 241, 169);">&quot;.&quot;</span> + img.type)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">with</span> open(filename, <span class="string" style="color: rgb(209, 241, 169);">&quot;wb&quot;</span>) <span class="keyword" style="color: rgb(235, 187, 255);">as</span> f:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            f.write(res.content)</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">__saveError</span><span class="params" style="color: rgb(255, 197, 143);">(self, message)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.lock.acquire()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">try</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            <span class="keyword" style="color: rgb(235, 187, 255);">with</span> open(self.errorFile, <span class="string" style="color: rgb(209, 241, 169);">&quot;a&quot;</span>, encoding=<span class="string" style="color: rgb(209, 241, 169);">&quot;utf-8&quot;</span>) <span class="keyword" style="color: rgb(235, 187, 255);">as</span> f:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">                f.write(message)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        <span class="keyword" style="color: rgb(235, 187, 255);">finally</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">            self.lock.release()</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="class"><span class="keyword" style="color: rgb(235, 187, 255);">class</span> <span class="title" style="color: rgb(153, 255, 255);">Image</span><span class="params" style="color: rgb(255, 197, 143);">(object)</span>:</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="string" style="color: rgb(209, 241, 169);">&quot;&quot;&quot;图片类，保存图片信息&quot;&quot;&quot;</span></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    <span class="function" style="color: rgb(187, 218, 255);"><span class="keyword" style="color: rgb(235, 187, 255);">def</span> <span class="title" style="color: rgb(153, 255, 255);">__init__</span><span class="params" style="color: rgb(255, 197, 143);">(self, url, type)</span>:</span></span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        super(Image, self).__init__()</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.url = url</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">        self.type = type</span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" data-filtered="filtered" style="height: 20px;"></span><br data-filtered="filtered" /><span class="line" style="height: 20px;"><span class="keyword" style="color: rgb(235, 187, 255);">if</span> __name__ == <span class="string" style="color: rgb(209, 241, 169);">'__main__'</span>:</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    print(<span class="string" style="color: rgb(209, 241, 169);">&quot;欢迎使用百度图片下载脚本！\n目前仅支持单个关键词。&quot;</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    print(<span class="string" style="color: rgb(209, 241, 169);">&quot;下载结果保存在脚本目录下的results文件夹中。&quot;</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    print(<span class="string" style="color: rgb(209, 241, 169);">&quot;=&quot;</span> * <span class="number" style="color: rgb(209, 241, 169);">50</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    word = input(<span class="string" style="color: rgb(209, 241, 169);">&quot;请输入你要下载的图片关键词：\n&quot;</span>)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    down = BaiduImgDownloader(word)</span><br data-filtered="filtered" /><span class="line" style="height: 20px;">    down.start()</span><br data-filtered="filtered" /></pre></td></tr></tbody></table></figure><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"></p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">执行脚本：</p><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 20px; margin-bottom: 20px; padding: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; text-align: justify;"><code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; padding: 0px; word-break: break-all; background: none; border-radius: 4px; text-shadow: none;">欢迎使用百度图片下载脚本！
目前仅支持单个关键词。
下载结果保存在脚本目录下的results文件夹中。
==================================================
请输入你要下载的图片关键词：
长者蛤
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">11.726878</span> **脚本开始执行
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">16.292022</span> **已获取 <span class="number" style="color: rgb(209, 241, 169);">20</span> 个Json请求网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">17.885767</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">30</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">17.917020</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
.....
.....中间省略
.....
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">33</span>:<span class="number" style="color: rgb(209, 241, 169);">31.726739</span> 已下载 <span class="number" style="color: rgb(209, 241, 169);">980</span> 张图片：http:<span class="comment" style="color: rgb(114, 133, 183);">//bbs.nantaihu.com/bbs/UpImages2008/2010/8/3/U97946_201083171218512-2.jpg</span>
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">33</span>:<span class="number" style="color: rgb(209, 241, 169);">32.695518</span> 已下载 <span class="number" style="color: rgb(209, 241, 169);">990</span> 张图片：http:<span class="comment" style="color: rgb(114, 133, 183);">//pf.u.51img1.com/f9/7f/huangbaoling0_180.gif?v=20120224161006</span>
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">33</span>:<span class="number" style="color: rgb(209, 241, 169);">45.473957</span> 已下载 <span class="number" style="color: rgb(209, 241, 169);">1000</span> 张图片：http:<span class="comment" style="color: rgb(114, 133, 183);">//library.taiwanschoolnet.org/cyberfair2003/C0312970394/narrative.files/image018.jpg</span>
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">33</span>:<span class="number" style="color: rgb(209, 241, 169);">50.749544</span> **下载完成！已下载 <span class="number" style="color: rgb(209, 241, 169);">1000</span> 张图片，总用时 <span class="number" style="color: rgb(209, 241, 169);">0</span>:<span class="number" style="color: rgb(209, 241, 169);">08</span>:<span class="number" style="color: rgb(209, 241, 169);">39.022666</span>
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">33</span>:<span class="number" style="color: rgb(209, 241, 169);">50.765169</span> **请到 F:\PythonWorkspace\Learn\results 查看结果！
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">33</span>:<span class="number" style="color: rgb(209, 241, 169);">50.858880</span> **错误信息保存在 F:\PythonWorkspace\Learn\errorUrl.txt
</code></pre><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">合租室友太多，平时网速很慢，经常连百度都打不开，要刷新多次。下午测试的时候可以2分钟下完，现在居然要近9分钟。</p><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"><code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">errorUrl.txt</code>的内容</p><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 20px; margin-bottom: 20px; padding: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; text-align: justify;"><code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; padding: 0px; word-break: break-all; background: none; border-radius: 4px; text-shadow: none;">无法打开图片： http:<span class="comment" style="color: rgb(114, 133, 183);">//s3.t.itc.cn/mblog/pic/20136_20_14/f_b3a1be1796819229739.png</span>
<span class="number" style="color: rgb(209, 241, 169);">403</span>： http:<span class="comment" style="color: rgb(114, 133, 183);">//www.longhoo.net/gb/longhoo/culture/view/images/00024483.jpg</span>
无法打开图片： http:<span class="comment" style="color: rgb(114, 133, 183);">//bhyjk.cn/images/IMG44zj10.jpg</span>
<span class="number" style="color: rgb(209, 241, 169);">404</span>： http:<span class="comment" style="color: rgb(114, 133, 183);">//ebook.indaa.com.cn/upload/baike/images/2960001-2970000/2968900/adee30ddd41190838c10291d.jpg</span>
抛出异常： http:<span class="comment" style="color: rgb(114, 133, 183);">//www.jzxzj.com/images/xs.jpg</span>
<span class="function" style="color: rgb(187, 218, 255);"><span class="title" style="color: rgb(153, 255, 255);">HTTPConnectionPool</span><span class="params" style="color: rgb(255, 197, 143);">(host=<span class="string" style="color: rgb(209, 241, 169);">'www.jzxzj.com'</span>, port=<span class="number" style="color: rgb(209, 241, 169);">80</span>)</span></span>: Max retries exceeded with url: /images/xs<span class="class">.jpg</span> (Caused by <span class="function" style="color: rgb(187, 218, 255);"><span class="title" style="color: rgb(153, 255, 255);">NewConnectionError</span><span class="params" style="color: rgb(255, 197, 143);">(<span class="string" style="color: rgb(209, 241, 169);">'&lt;requests.packages.urllib3.connection.HTTPConnection object at 0x0851FBB0&gt;: Failed to establish a new connection: [Errno 11002] getaddrinfo failed'</span>,)</span></span>)
抛出异常： http:<span class="comment" style="color: rgb(114, 133, 183);">//static.acfun.mm111.net/h/image/20147/846b7553851b6edb2305c6b87f4aed71.jpg</span>
<span class="function" style="color: rgb(187, 218, 255);"><span class="title" style="color: rgb(153, 255, 255);">HTTPConnectionPool</span><span class="params" style="color: rgb(255, 197, 143);">(host=<span class="string" style="color: rgb(209, 241, 169);">'static.acfun.mm111.net'</span>, port=<span class="number" style="color: rgb(209, 241, 169);">80</span>)</span></span>: Max retries exceeded with url: /h/image/<span class="number" style="color: rgb(209, 241, 169);">20147</span>/<span class="number" style="color: rgb(209, 241, 169);">846</span>b7553851b6edb2305c6b87f4aed71<span class="class">.jpg</span> (Caused by <span class="function" style="color: rgb(187, 218, 255);"><span class="title" style="color: rgb(153, 255, 255);">NewConnectionError</span><span class="params" style="color: rgb(255, 197, 143);">(<span class="string" style="color: rgb(209, 241, 169);">'&lt;requests.packages.urllib3.connection.HTTPConnection object at 0x0888B710&gt;: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'</span>,)</span></span>)
抛出异常： http:<span class="comment" style="color: rgb(114, 133, 183);">//static.acfun.mm111.net/h/image/2015-0-4/23ebeaf5-5130-4072-b90e-48ce4d122ac8.jpg</span>
<span class="function" style="color: rgb(187, 218, 255);"><span class="title" style="color: rgb(153, 255, 255);">HTTPConnectionPool</span><span class="params" style="color: rgb(255, 197, 143);">(host=<span class="string" style="color: rgb(209, 241, 169);">'static.acfun.mm111.net'</span>, port=<span class="number" style="color: rgb(209, 241, 169);">80</span>)</span></span>: Max retries exceeded with url: /h/image/<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">0</span>-<span class="number" style="color: rgb(209, 241, 169);">4</span>/<span class="number" style="color: rgb(209, 241, 169);">23</span>ebeaf5-<span class="number" style="color: rgb(209, 241, 169);">5130</span>-<span class="number" style="color: rgb(209, 241, 169);">4072</span>-b90e-<span class="number" style="color: rgb(209, 241, 169);">48</span>ce4d122ac8<span class="class">.jpg</span> (Caused by <span class="function" style="color: rgb(187, 218, 255);"><span class="title" style="color: rgb(153, 255, 255);">NewConnectionError</span><span class="params" style="color: rgb(255, 197, 143);">(<span class="string" style="color: rgb(209, 241, 169);">'&lt;requests.packages.urllib3.connection.HTTPConnection object at 0x0888F1F0&gt;: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'</span>,)</span></span>)
<span class="number" style="color: rgb(209, 241, 169);">404</span>： http:<span class="comment" style="color: rgb(114, 133, 183);">//www.zipooo.com/tupian/1/%CE%EF%C1%F7%BF%EC%B5%DD.gif</span>
无法打开图片： http:<span class="comment" style="color: rgb(114, 133, 183);">//www.zhiyin.cn/hsbk/fakeimg/7939883.jpeg</span>
无法打开图片： http:<span class="comment" style="color: rgb(114, 133, 183);">//www.zhiyin.cn/hsbk/fakeimg/21753396.jpeg</span>
.....
</code></pre><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"><code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; padding: 2px 4px; word-break: break-all; color: rgb(221, 0, 85); background: rgb(238, 238, 238); border-radius: 4px;">logInfo.txt</code>内容：</p><pre style="overflow: auto; font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; font-size: 15px; margin-top: 20px; margin-bottom: 20px; padding: 15px; color: rgb(255, 255, 255); background: rgb(0, 36, 81); line-height: 1.6; text-align: justify;"><code style="font-family: &quot;Microsoft YaHei Mono&quot;, consolas, Menlo, &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, monospace; padding: 0px; word-break: break-all; background: none; border-radius: 4px; text-shadow: none;"><span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">11.726878</span> **脚本开始执行
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">16.292022</span> **已获取 <span class="number" style="color: rgb(209, 241, 169);">20</span> 个Json请求网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">17.885767</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">30</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">17.917020</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">17.948262</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">17.963895</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">17.995146</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.010769</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.057638</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.057638</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.073264</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.073264</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.088890</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.088890</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.104516</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.104516</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.104516</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.104516</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.245137</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.260764</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.260764</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">18.479555</span> **已解析出 <span class="number" style="color: rgb(209, 241, 169);">60</span> 个图片网址
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">27.532965</span> 已下载 <span class="number" style="color: rgb(209, 241, 169);">1</span> 张图片：http:<span class="comment" style="color: rgb(114, 133, 183);">//imgsrc.baidu.com/baike/abpic/item/43e6c7335b379350ad4b5f92.jpg</span>
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">29.084964</span>
无法打开图片： http:<span class="comment" style="color: rgb(114, 133, 183);">//s3.t.itc.cn/mblog/pic/20136_20_14/f_b3a1be1796819229739.png</span>
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">29.522473</span> 已下载 <span class="number" style="color: rgb(209, 241, 169);">2</span> 张图片：http:<span class="comment" style="color: rgb(114, 133, 183);">//p4.qhimg.com/dr/200_200_/t0196ad8cefbc7a2c7c.jpg</span>
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">29.822650</span> 已下载 <span class="number" style="color: rgb(209, 241, 169);">3</span> 张图片：http:<span class="comment" style="color: rgb(114, 133, 183);">//library.taiwanschoolnet.org/cyberfair2003/C0312970394/narrative.files/image016.jpg</span>
<span class="number" style="color: rgb(209, 241, 169);">2015</span>-<span class="number" style="color: rgb(209, 241, 169);">11</span>-<span class="number" style="color: rgb(209, 241, 169);">15</span> <span class="number" style="color: rgb(209, 241, 169);">19</span>:<span class="number" style="color: rgb(209, 241, 169);">25</span>:<span class="number" style="color: rgb(209, 241, 169);">29.938687</span> 已下载 <span class="number" style="color: rgb(209, 241, 169);">4</span> 张图片：http:<span class="comment" style="color: rgb(114, 133, 183);">//blog.ylib.com/public/Utilities/ImageReader.aspx?/0/6/06c67eaf-09db-40a8-a117-c577a6d05d08.jpg</span>
....
</code></pre><p style="margin-top: 0px; margin-bottom: 25px; color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;">仍然可以改进的地方：</p><ol style="color: rgb(85, 85, 85); font-family: &quot;PingFang SC&quot;, &quot;Microsoft YaHei&quot;, sans-serif; font-size: 16px; text-align: justify;"><li>如果要搜索多个关键词，buildUrls方法应该怎么改？</li><li>如果脚本中途意外结束（比如被熊孩子点了X），如何继续下载？</li><li>线程池中的线程数需要多次测试才能找到最优值。</li></ol>   
</div>








    <div class="readall_box csdn-tracking-statistics tracking-click"  data-pid="blog"  data-mod="popu_596">
        <div class="read_more_mask"></div>
        <a class="btn btn-large btn-gray-fred read_more_btn" target="_self">阅读全文</a>
    </div>

    <div class="csdn-tracking-statistics" data-pid="blog"  data-mod="popu_222"><a href="javascript:void(0);" >&nbsp;</a>   </div>
    <div class="csdn-tracking-statistics" data-pid="blog"  data-mod="popu_223"> <a href="javascript:void(0);" >&nbsp;</a></div>
        <div id="digg" ArticleId="78730200" >
            <dl id="btnDigg" class="digg digg_disable"  onclick="btndigga();">
               
                 <dt>顶</dt>
                <dd>1</dd>
            </dl>
           
              
            <dl id="btnBury" class="digg digg_disable"  onclick="btnburya();">
              
                  <dt>踩</dt>
                <dd>0</dd>               
            </dl>
            
        </div>
    <script type="text/javascript">
        function btndigga() {
            $(".csdn-tracking-statistics[data-mod='popu_222'] a").click();
        }
        function btnburya() {
            $(".csdn-tracking-statistics[data-mod='popu_223'] a").click();
        }
            </script>

   <ul class="article_next_prev">
                <li class="prev_article"><span  onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shangyipian']);location.href='http://blog.csdn.net/guyuealian/article/details/78684523';">上一篇</span><a href="http://blog.csdn.net/guyuealian/article/details/78684523" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_shangyipian'])">OpenCV3.0或OpenCV3.1的SVM操作</a></li>
                <li class="next_article"><span onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_xiayipian']);location.href='http://blog.csdn.net/guyuealian/article/details/78731187';">下一篇</span><a href="http://blog.csdn.net/guyuealian/article/details/78731187" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_xiayipian'])">OpenCV HOGDescriptor 参数图解</a></li>
    </ul>

    <div style="clear:both; height:10px;"></div>

   
      
</div>

     <div>
         
         <!-- 广告位：PC端-博客详情页底部banner-960*90 -->
            <script>
                (function() {
                    var s = "_" + Math.random().toString(36).slice(2);
                    document.write('<div id="' + s + '"></div>');
                    (window.slotbydup=window.slotbydup || []).push({
                        id: '4770928',
                        container: s,
                        size: '960,90',
                        display: 'inlay-fix'
                    });
                })();
            </script>
    </div>

<div id="suggest"></div>
         <script  language="javascript" type='text/javascript'>     
             $(function(){
                 $.get("/guyuealian/svc/GetSuggestContent/78730200",function(data){
                     $("#suggest").html(data);
                 });     
             });             
         </script>  




            
                                    
            
                                    

        <!-- 广告位开始 -->
        <!-- 广告位结束 -->



<div class="comment_class">
	<div class="commentform"><!--<div class="panel_head">发表评论</div>--></div>
    <div id="comment_form">

    </div>
    <div id="comment_title" class="panel_head">
        <span class="see_comment">查看评论</span><a name="comments"></a></div>
    <div id="comment_list">
	
    </div>
    <div id="comment_bar">
    </div>
    <!--<div class="announce">
        * 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场<a name="reply"></a><a name="quote"></a></div>-->
</div>
<div class="recommend_list">

    
            <dl class="clearfix csdn-tracking-statistics recommend_article" data-mod="popu_614" data-poputype="feed"  data-feed-show="false"  data-dsm="post">
<a href="/cch1024/article/details/54601591"  target="_blank" strategy="BlogCommendFromBaidu_0">
                <dd>
                    <h2>Python 爬虫多线程爬取美女图片保存到本地</h2>
                    <div class="summary">
                        Wanning
  我们不是生产者,我们只是搬运工
资源来至于qiubaichengren ，代码基于Python 3.5.2 
友情提醒：血气方刚的骚年。请谨慎 阅图 ！！！ 
谨慎 阅图 ！！！ 
谨慎 阅图 ！！！code：#!/usr/bin/env python
# -*- coding:...
                    </div>
                    <ul>
                        <li class="avatar_img"><img src="http://avatar.csdn.net/0/E/F/2_cch1024.jpg" alt="cch1024" title="cch1024"></li>
                        <li class="user_name">cch1024</li>
                        <li class="time">2017-01-18 15:24</li>
                        <li class="visited_num"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"   fill = "#ccc"><defs><style/></defs><path d="M988.16 240.64c0-5.12-2.56-11.52-6.4-15.36-2.56-2.56-51.2-55.04-135.68-81.92-32-10.24-64-15.36-96-15.36-97.28 0-181.76 46.08-235.52 84.48-55.04-39.68-139.52-85.76-236.8-85.76-32 0-65.28 5.12-96 15.36C97.28 168.96 49.92 224 47.36 226.56c-3.84 3.84-5.12 8.96-5.12 15.36v546.56l60.16 71.68c3.84 8.96 12.8 15.36 21.76 15.36 3.84 0 7.68 0 10.24-2.56 19.2-5.12 120.32-29.44 199.68-29.44 37.12 0 64 5.12 79.36 15.36 7.68 5.12 11.52 10.24 12.8 16.64 0 12.8 10.24 23.04 23.04 23.04h21.76c24.32 0 61.44 0 98.56-2.56h5.12c10.24 0 20.48-7.68 23.04-17.92 2.56-10.24 7.68-16.64 17.92-23.04 16.64-8.96 42.24-14.08 76.8-14.08 78.08 0 171.52 24.32 198.4 32 3.84 1.28 7.68 2.56 11.52 2.56 8.96 0 17.92-5.12 21.76-14.08l64-72.96V240.64zM88.32 744.96V250.88c14.08-14.08 52.48-46.08 107.52-64 26.88-8.96 53.76-12.8 81.92-12.8 70.4 0 142.08 26.88 213.76 79.36v477.44c-38.4-23.04-88.32-34.56-149.76-34.56-32 0-66.56 3.84-102.4 10.24-60.16 8.96-115.2 26.88-151.04 38.4zm805.12 79.36c-20.48-5.12-61.44-15.36-106.24-23.04-35.84-5.12-66.56-7.68-94.72-7.68-43.52 0-76.8 6.4-101.12 20.48-15.36 8.96-26.88 20.48-33.28 34.56-33.28 1.28-65.28 2.56-87.04 2.56h-3.84c-6.4-12.8-15.36-24.32-29.44-32-23.04-15.36-58.88-21.76-106.24-21.76-76.8 0-165.12 19.2-200.96 28.16l-29.44-35.84c51.2-17.92 148.48-47.36 240.64-47.36 70.4 0 122.88 17.92 153.6 52.48l2.56 2.56 1.28 1.28 1.28 1.28 1.28 1.28h1.28l2.56 1.28h11.52l2.56-1.28h1.28s1.28 0 1.28-1.28h1.28s1.28 0 1.28-1.28h1.28l2.56-2.56c30.72-37.12 81.92-56.32 152.32-56.32 39.68 0 122.88 6.4 240.64 49.92l-28.16 34.56zm47.36-79.36c-35.84-14.08-90.88-32-152.32-43.52-37.12-6.4-71.68-10.24-103.68-10.24-60.16 0-110.08 12.8-148.48 37.12V253.44c70.4-51.2 142.08-78.08 212.48-78.08 28.16 0 55.04 3.84 81.92 12.8 56.32 17.92 94.72 49.92 110.08 64v492.8z"/></svg><span>2745</span></li>
                    </ul>
                </dd>
</a>
            </dl>
            
            <dl class="clearfix csdn-tracking-statistics recommend_article" data-mod="popu_614" data-poputype="feed"  data-feed-show="false"  data-dsm="post">
<a href="/pzqingchong/article/details/77725625"  target="_blank" strategy="BlogCommendFromBaidu_1">
                <dd>
                    <h2>python多线程下载图片</h2>
                    <div class="summary">
                        python 多线程
                    </div>
                    <ul>
                        <li class="avatar_img"><img src="http://avatar.csdn.net/F/C/3/2_pzqingchong.jpg" alt="pzqingchong" title="pzqingchong"></li>
                        <li class="user_name">pzqingchong</li>
                        <li class="time">2017-08-30 21:09</li>
                        <li class="visited_num"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"   fill = "#ccc"><defs><style/></defs><path d="M988.16 240.64c0-5.12-2.56-11.52-6.4-15.36-2.56-2.56-51.2-55.04-135.68-81.92-32-10.24-64-15.36-96-15.36-97.28 0-181.76 46.08-235.52 84.48-55.04-39.68-139.52-85.76-236.8-85.76-32 0-65.28 5.12-96 15.36C97.28 168.96 49.92 224 47.36 226.56c-3.84 3.84-5.12 8.96-5.12 15.36v546.56l60.16 71.68c3.84 8.96 12.8 15.36 21.76 15.36 3.84 0 7.68 0 10.24-2.56 19.2-5.12 120.32-29.44 199.68-29.44 37.12 0 64 5.12 79.36 15.36 7.68 5.12 11.52 10.24 12.8 16.64 0 12.8 10.24 23.04 23.04 23.04h21.76c24.32 0 61.44 0 98.56-2.56h5.12c10.24 0 20.48-7.68 23.04-17.92 2.56-10.24 7.68-16.64 17.92-23.04 16.64-8.96 42.24-14.08 76.8-14.08 78.08 0 171.52 24.32 198.4 32 3.84 1.28 7.68 2.56 11.52 2.56 8.96 0 17.92-5.12 21.76-14.08l64-72.96V240.64zM88.32 744.96V250.88c14.08-14.08 52.48-46.08 107.52-64 26.88-8.96 53.76-12.8 81.92-12.8 70.4 0 142.08 26.88 213.76 79.36v477.44c-38.4-23.04-88.32-34.56-149.76-34.56-32 0-66.56 3.84-102.4 10.24-60.16 8.96-115.2 26.88-151.04 38.4zm805.12 79.36c-20.48-5.12-61.44-15.36-106.24-23.04-35.84-5.12-66.56-7.68-94.72-7.68-43.52 0-76.8 6.4-101.12 20.48-15.36 8.96-26.88 20.48-33.28 34.56-33.28 1.28-65.28 2.56-87.04 2.56h-3.84c-6.4-12.8-15.36-24.32-29.44-32-23.04-15.36-58.88-21.76-106.24-21.76-76.8 0-165.12 19.2-200.96 28.16l-29.44-35.84c51.2-17.92 148.48-47.36 240.64-47.36 70.4 0 122.88 17.92 153.6 52.48l2.56 2.56 1.28 1.28 1.28 1.28 1.28 1.28h1.28l2.56 1.28h11.52l2.56-1.28h1.28s1.28 0 1.28-1.28h1.28s1.28 0 1.28-1.28h1.28l2.56-2.56c30.72-37.12 81.92-56.32 152.32-56.32 39.68 0 122.88 6.4 240.64 49.92l-28.16 34.56zm47.36-79.36c-35.84-14.08-90.88-32-152.32-43.52-37.12-6.4-71.68-10.24-103.68-10.24-60.16 0-110.08 12.8-148.48 37.12V253.44c70.4-51.2 142.08-78.08 212.48-78.08 28.16 0 55.04 3.84 81.92 12.8 56.32 17.92 94.72 49.92 110.08 64v492.8z"/></svg><span>162</span></li>
                    </ul>
                </dd>
</a>
            </dl>
            <script>(function() {var s = "_" + Math.random().toString(36).slice(2);document.write('<div id="' + s + '"></div>');(window.slotbydup = window.slotbydup || []).push({id: '4765209',container: s,size: '808,120',display: 'inlay-fix'});})();</script> 
            <dl class="clearfix csdn-tracking-statistics recommend_article" data-mod="popu_614" data-poputype="feed"  data-feed-show="false"  data-dsm="post">
<a href="/dsc114/article/details/74231085"  target="_blank" strategy="BlogCommendFromQuerySearch_2">
                <dd>
                    <h2>Fiddler抓取主流新闻客户端搜索url</h2>
                    <div class="summary">
                        仅仅是学习Fiddler，无商用，如有侵权请告知作者删除本文。今日头条：（webview） 
https://is.snssdk.com/api/2/wap/search/?from=search_tab&amp;keyword=%E9%9B%84%E5%AE%89%E6%96%B0%E5%8C%B...
                    </div>
                    <ul>
                        <li class="avatar_img"><img src="http://avatar.csdn.net/4/D/6/2_dsc114.jpg" alt="dsc114" title="dsc114"></li>
                        <li class="user_name">dsc114</li>
                        <li class="time">2017-07-03 17:32</li>
                        <li class="visited_num"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"   fill = "#ccc"><defs><style/></defs><path d="M988.16 240.64c0-5.12-2.56-11.52-6.4-15.36-2.56-2.56-51.2-55.04-135.68-81.92-32-10.24-64-15.36-96-15.36-97.28 0-181.76 46.08-235.52 84.48-55.04-39.68-139.52-85.76-236.8-85.76-32 0-65.28 5.12-96 15.36C97.28 168.96 49.92 224 47.36 226.56c-3.84 3.84-5.12 8.96-5.12 15.36v546.56l60.16 71.68c3.84 8.96 12.8 15.36 21.76 15.36 3.84 0 7.68 0 10.24-2.56 19.2-5.12 120.32-29.44 199.68-29.44 37.12 0 64 5.12 79.36 15.36 7.68 5.12 11.52 10.24 12.8 16.64 0 12.8 10.24 23.04 23.04 23.04h21.76c24.32 0 61.44 0 98.56-2.56h5.12c10.24 0 20.48-7.68 23.04-17.92 2.56-10.24 7.68-16.64 17.92-23.04 16.64-8.96 42.24-14.08 76.8-14.08 78.08 0 171.52 24.32 198.4 32 3.84 1.28 7.68 2.56 11.52 2.56 8.96 0 17.92-5.12 21.76-14.08l64-72.96V240.64zM88.32 744.96V250.88c14.08-14.08 52.48-46.08 107.52-64 26.88-8.96 53.76-12.8 81.92-12.8 70.4 0 142.08 26.88 213.76 79.36v477.44c-38.4-23.04-88.32-34.56-149.76-34.56-32 0-66.56 3.84-102.4 10.24-60.16 8.96-115.2 26.88-151.04 38.4zm805.12 79.36c-20.48-5.12-61.44-15.36-106.24-23.04-35.84-5.12-66.56-7.68-94.72-7.68-43.52 0-76.8 6.4-101.12 20.48-15.36 8.96-26.88 20.48-33.28 34.56-33.28 1.28-65.28 2.56-87.04 2.56h-3.84c-6.4-12.8-15.36-24.32-29.44-32-23.04-15.36-58.88-21.76-106.24-21.76-76.8 0-165.12 19.2-200.96 28.16l-29.44-35.84c51.2-17.92 148.48-47.36 240.64-47.36 70.4 0 122.88 17.92 153.6 52.48l2.56 2.56 1.28 1.28 1.28 1.28 1.28 1.28h1.28l2.56 1.28h11.52l2.56-1.28h1.28s1.28 0 1.28-1.28h1.28s1.28 0 1.28-1.28h1.28l2.56-2.56c30.72-37.12 81.92-56.32 152.32-56.32 39.68 0 122.88 6.4 240.64 49.92l-28.16 34.56zm47.36-79.36c-35.84-14.08-90.88-32-152.32-43.52-37.12-6.4-71.68-10.24-103.68-10.24-60.16 0-110.08 12.8-148.48 37.12V253.44c70.4-51.2 142.08-78.08 212.48-78.08 28.16 0 55.04 3.84 81.92 12.8 56.32 17.92 94.72 49.92 110.08 64v492.8z"/></svg><span>1799</span></li>
                    </ul>
                </dd>
</a>
            </dl>
            
            <dl class="clearfix csdn-tracking-statistics recommend_article" data-mod="popu_614" data-poputype="feed"  data-feed-show="false"  data-dsm="post">
<a href="/qq_28551705/article/details/53305891"  target="_blank" strategy="BlogCommendFromQuerySearch_3">
                <dd>
                    <h2>有关上传到APPStore上iphone5,5c,4s下载应用,出现该APP与设备不兼容问题</h2>
                    <div class="summary">
                        上架的app,用5c,4s,5不能够下载,提示APP和设备不兼容问题.之前也出现过上传到蒲公英,生成测试包的时候,也出现这问题,也就没在意.后来询问蒲公英客服,给回了邮件,才发现也是这个原因导致的.
解决办法:
也就是把Build Settings 里面的Build Active Archite...
                    </div>
                    <ul>
                        <li class="avatar_img"><img src="http://avatar.csdn.net/4/D/3/2_qq_28551705.jpg" alt="qq_28551705" title="qq_28551705"></li>
                        <li class="user_name">qq_28551705</li>
                        <li class="time">2016-11-23 15:26</li>
                        <li class="visited_num"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"   fill = "#ccc"><defs><style/></defs><path d="M988.16 240.64c0-5.12-2.56-11.52-6.4-15.36-2.56-2.56-51.2-55.04-135.68-81.92-32-10.24-64-15.36-96-15.36-97.28 0-181.76 46.08-235.52 84.48-55.04-39.68-139.52-85.76-236.8-85.76-32 0-65.28 5.12-96 15.36C97.28 168.96 49.92 224 47.36 226.56c-3.84 3.84-5.12 8.96-5.12 15.36v546.56l60.16 71.68c3.84 8.96 12.8 15.36 21.76 15.36 3.84 0 7.68 0 10.24-2.56 19.2-5.12 120.32-29.44 199.68-29.44 37.12 0 64 5.12 79.36 15.36 7.68 5.12 11.52 10.24 12.8 16.64 0 12.8 10.24 23.04 23.04 23.04h21.76c24.32 0 61.44 0 98.56-2.56h5.12c10.24 0 20.48-7.68 23.04-17.92 2.56-10.24 7.68-16.64 17.92-23.04 16.64-8.96 42.24-14.08 76.8-14.08 78.08 0 171.52 24.32 198.4 32 3.84 1.28 7.68 2.56 11.52 2.56 8.96 0 17.92-5.12 21.76-14.08l64-72.96V240.64zM88.32 744.96V250.88c14.08-14.08 52.48-46.08 107.52-64 26.88-8.96 53.76-12.8 81.92-12.8 70.4 0 142.08 26.88 213.76 79.36v477.44c-38.4-23.04-88.32-34.56-149.76-34.56-32 0-66.56 3.84-102.4 10.24-60.16 8.96-115.2 26.88-151.04 38.4zm805.12 79.36c-20.48-5.12-61.44-15.36-106.24-23.04-35.84-5.12-66.56-7.68-94.72-7.68-43.52 0-76.8 6.4-101.12 20.48-15.36 8.96-26.88 20.48-33.28 34.56-33.28 1.28-65.28 2.56-87.04 2.56h-3.84c-6.4-12.8-15.36-24.32-29.44-32-23.04-15.36-58.88-21.76-106.24-21.76-76.8 0-165.12 19.2-200.96 28.16l-29.44-35.84c51.2-17.92 148.48-47.36 240.64-47.36 70.4 0 122.88 17.92 153.6 52.48l2.56 2.56 1.28 1.28 1.28 1.28 1.28 1.28h1.28l2.56 1.28h11.52l2.56-1.28h1.28s1.28 0 1.28-1.28h1.28s1.28 0 1.28-1.28h1.28l2.56-2.56c30.72-37.12 81.92-56.32 152.32-56.32 39.68 0 122.88 6.4 240.64 49.92l-28.16 34.56zm47.36-79.36c-35.84-14.08-90.88-32-152.32-43.52-37.12-6.4-71.68-10.24-103.68-10.24-60.16 0-110.08 12.8-148.48 37.12V253.44c70.4-51.2 142.08-78.08 212.48-78.08 28.16 0 55.04 3.84 81.92 12.8 56.32 17.92 94.72 49.92 110.08 64v492.8z"/></svg><span>646</span></li>
                    </ul>
                </dd>
</a>
            </dl>
            <!-- 广告位：PC端-博客详情通栏7（feed流）-808*120 --><script async="async" charset="utf-8" src="https://shared.ydstatic.com/js/yatdk/3.0.0/stream.js"  data-id="8935aa488dd58452b9e5ee3b44f1212f" data-hide-ad-label = "0"  data-div-Style="width:100%; padding: 16px 35px 16px 10px; border-bottom:1px solid #f4f4f4;" data-img-Style="float:right;width:120px;"  data-tit-Style="font-size:20px;font-weight:bold;margin-bottom:10px;font-family:'PingFang SC','Microsoft YaHei',SimHei,Arial,SimSun;"  data-des-Style="width:700px;font-size:14px;font-family:'PingFang SC','Microsoft YaHei',SimHei,Arial,SimSun;"> </script>
            <dl class="clearfix csdn-tracking-statistics recommend_article" data-mod="popu_614" data-poputype="feed"  data-feed-show="false"  data-dsm="post">
<a href="/shu_8708/article/details/75127588"  target="_blank" strategy="BlogCommendFromQuerySearch_4">
                <dd>
                    <h2>Python多线程爬虫获取电影下载链接</h2>
                    <div class="summary">
                        一些电影资源网站往往广告太多，不想看广告所以做了这个程序
首先需要先分析网站的搜索链接，这里只用到了“爱下电影网”和“电影天堂”两个网站
爱下电影：http://www.aixia.cc/plus/search.php?searchtype=titlekeyword&amp;q=%E9%80%9F%...
                    </div>
                    <ul>
                        <li class="avatar_img"><img src="http://avatar.csdn.net/E/3/5/2_shu_8708.jpg" alt="shu_8708" title="shu_8708"></li>
                        <li class="user_name">shu_8708</li>
                        <li class="time">2017-07-14 18:53</li>
                        <li class="visited_num"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"   fill = "#ccc"><defs><style/></defs><path d="M988.16 240.64c0-5.12-2.56-11.52-6.4-15.36-2.56-2.56-51.2-55.04-135.68-81.92-32-10.24-64-15.36-96-15.36-97.28 0-181.76 46.08-235.52 84.48-55.04-39.68-139.52-85.76-236.8-85.76-32 0-65.28 5.12-96 15.36C97.28 168.96 49.92 224 47.36 226.56c-3.84 3.84-5.12 8.96-5.12 15.36v546.56l60.16 71.68c3.84 8.96 12.8 15.36 21.76 15.36 3.84 0 7.68 0 10.24-2.56 19.2-5.12 120.32-29.44 199.68-29.44 37.12 0 64 5.12 79.36 15.36 7.68 5.12 11.52 10.24 12.8 16.64 0 12.8 10.24 23.04 23.04 23.04h21.76c24.32 0 61.44 0 98.56-2.56h5.12c10.24 0 20.48-7.68 23.04-17.92 2.56-10.24 7.68-16.64 17.92-23.04 16.64-8.96 42.24-14.08 76.8-14.08 78.08 0 171.52 24.32 198.4 32 3.84 1.28 7.68 2.56 11.52 2.56 8.96 0 17.92-5.12 21.76-14.08l64-72.96V240.64zM88.32 744.96V250.88c14.08-14.08 52.48-46.08 107.52-64 26.88-8.96 53.76-12.8 81.92-12.8 70.4 0 142.08 26.88 213.76 79.36v477.44c-38.4-23.04-88.32-34.56-149.76-34.56-32 0-66.56 3.84-102.4 10.24-60.16 8.96-115.2 26.88-151.04 38.4zm805.12 79.36c-20.48-5.12-61.44-15.36-106.24-23.04-35.84-5.12-66.56-7.68-94.72-7.68-43.52 0-76.8 6.4-101.12 20.48-15.36 8.96-26.88 20.48-33.28 34.56-33.28 1.28-65.28 2.56-87.04 2.56h-3.84c-6.4-12.8-15.36-24.32-29.44-32-23.04-15.36-58.88-21.76-106.24-21.76-76.8 0-165.12 19.2-200.96 28.16l-29.44-35.84c51.2-17.92 148.48-47.36 240.64-47.36 70.4 0 122.88 17.92 153.6 52.48l2.56 2.56 1.28 1.28 1.28 1.28 1.28 1.28h1.28l2.56 1.28h11.52l2.56-1.28h1.28s1.28 0 1.28-1.28h1.28s1.28 0 1.28-1.28h1.28l2.56-2.56c30.72-37.12 81.92-56.32 152.32-56.32 39.68 0 122.88 6.4 240.64 49.92l-28.16 34.56zm47.36-79.36c-35.84-14.08-90.88-32-152.32-43.52-37.12-6.4-71.68-10.24-103.68-10.24-60.16 0-110.08 12.8-148.48 37.12V253.44c70.4-51.2 142.08-78.08 212.48-78.08 28.16 0 55.04 3.84 81.92 12.8 56.32 17.92 94.72 49.92 110.08 64v492.8z"/></svg><span>1059</span></li>
                    </ul>
                </dd>
</a>
            </dl>
            
            <dl class="clearfix csdn-tracking-statistics recommend_article" data-mod="popu_614" data-poputype="feed"  data-feed-show="false"  data-dsm="post">
<a href="/victoryckl/article/details/6995418"  target="_blank" strategy="BlogCommendFromQuerySearch_5">
                <dd>
                    <h2>Permission Denial:  reading com.android.browser.BrowserProvider uri content://browser/bookmarks</h2>
                    <div class="summary">
                        http://www.eoeandroid.com/thread-56735-1-1.html
按照http://abomby.blog.sohu.com/166121477.html配置了一下，在eclipse里面试图运行浏览器，结果出现这些errors：
具体是哪一个error使得我的应用程...
                    </div>
                    <ul>
                        <li class="avatar_img"><img src="http://avatar.csdn.net/2/6/D/2_victoryckl.jpg" alt="victoryckl" title="victoryckl"></li>
                        <li class="user_name">victoryckl</li>
                        <li class="time">2011-11-21 10:03</li>
                        <li class="visited_num"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"   fill = "#ccc"><defs><style/></defs><path d="M988.16 240.64c0-5.12-2.56-11.52-6.4-15.36-2.56-2.56-51.2-55.04-135.68-81.92-32-10.24-64-15.36-96-15.36-97.28 0-181.76 46.08-235.52 84.48-55.04-39.68-139.52-85.76-236.8-85.76-32 0-65.28 5.12-96 15.36C97.28 168.96 49.92 224 47.36 226.56c-3.84 3.84-5.12 8.96-5.12 15.36v546.56l60.16 71.68c3.84 8.96 12.8 15.36 21.76 15.36 3.84 0 7.68 0 10.24-2.56 19.2-5.12 120.32-29.44 199.68-29.44 37.12 0 64 5.12 79.36 15.36 7.68 5.12 11.52 10.24 12.8 16.64 0 12.8 10.24 23.04 23.04 23.04h21.76c24.32 0 61.44 0 98.56-2.56h5.12c10.24 0 20.48-7.68 23.04-17.92 2.56-10.24 7.68-16.64 17.92-23.04 16.64-8.96 42.24-14.08 76.8-14.08 78.08 0 171.52 24.32 198.4 32 3.84 1.28 7.68 2.56 11.52 2.56 8.96 0 17.92-5.12 21.76-14.08l64-72.96V240.64zM88.32 744.96V250.88c14.08-14.08 52.48-46.08 107.52-64 26.88-8.96 53.76-12.8 81.92-12.8 70.4 0 142.08 26.88 213.76 79.36v477.44c-38.4-23.04-88.32-34.56-149.76-34.56-32 0-66.56 3.84-102.4 10.24-60.16 8.96-115.2 26.88-151.04 38.4zm805.12 79.36c-20.48-5.12-61.44-15.36-106.24-23.04-35.84-5.12-66.56-7.68-94.72-7.68-43.52 0-76.8 6.4-101.12 20.48-15.36 8.96-26.88 20.48-33.28 34.56-33.28 1.28-65.28 2.56-87.04 2.56h-3.84c-6.4-12.8-15.36-24.32-29.44-32-23.04-15.36-58.88-21.76-106.24-21.76-76.8 0-165.12 19.2-200.96 28.16l-29.44-35.84c51.2-17.92 148.48-47.36 240.64-47.36 70.4 0 122.88 17.92 153.6 52.48l2.56 2.56 1.28 1.28 1.28 1.28 1.28 1.28h1.28l2.56 1.28h11.52l2.56-1.28h1.28s1.28 0 1.28-1.28h1.28s1.28 0 1.28-1.28h1.28l2.56-2.56c30.72-37.12 81.92-56.32 152.32-56.32 39.68 0 122.88 6.4 240.64 49.92l-28.16 34.56zm47.36-79.36c-35.84-14.08-90.88-32-152.32-43.52-37.12-6.4-71.68-10.24-103.68-10.24-60.16 0-110.08 12.8-148.48 37.12V253.44c70.4-51.2 142.08-78.08 212.48-78.08 28.16 0 55.04 3.84 81.92 12.8 56.32 17.92 94.72 49.92 110.08 64v492.8z"/></svg><span>2176</span></li>
                    </ul>
                </dd>
</a>
            </dl>
            
            <dl class="clearfix csdn-tracking-statistics recommend_article" data-mod="popu_614" data-poputype="feed"  data-feed-show="false"  data-dsm="post">
<a href="/honjane/article/details/54411820"  target="_blank" strategy="BlogCommendFromQuerySearch_6">
                <dd>
                    <h2>解决 Android N 上报错：android.os.FileUriExposedException: file:///storage/emulated/0/</h2>
                    <div class="summary">
                        解决android N文件访问crash android.os.FileUriExposedException  file:///storage/emulated/0/xxx原因：Android N对访问文件权限收回，按照Android N的要求，若要在应用间共享文件，您应发送一项 content:...
                    </div>
                    <ul>
                        <li class="avatar_img"><img src="http://avatar.csdn.net/F/3/0/2_tsdfk1455.jpg" alt="tsdfk1455" title="tsdfk1455"></li>
                        <li class="user_name">tsdfk1455</li>
                        <li class="time">2017-01-13 20:32</li>
                        <li class="visited_num"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"   fill = "#ccc"><defs><style/></defs><path d="M988.16 240.64c0-5.12-2.56-11.52-6.4-15.36-2.56-2.56-51.2-55.04-135.68-81.92-32-10.24-64-15.36-96-15.36-97.28 0-181.76 46.08-235.52 84.48-55.04-39.68-139.52-85.76-236.8-85.76-32 0-65.28 5.12-96 15.36C97.28 168.96 49.92 224 47.36 226.56c-3.84 3.84-5.12 8.96-5.12 15.36v546.56l60.16 71.68c3.84 8.96 12.8 15.36 21.76 15.36 3.84 0 7.68 0 10.24-2.56 19.2-5.12 120.32-29.44 199.68-29.44 37.12 0 64 5.12 79.36 15.36 7.68 5.12 11.52 10.24 12.8 16.64 0 12.8 10.24 23.04 23.04 23.04h21.76c24.32 0 61.44 0 98.56-2.56h5.12c10.24 0 20.48-7.68 23.04-17.92 2.56-10.24 7.68-16.64 17.92-23.04 16.64-8.96 42.24-14.08 76.8-14.08 78.08 0 171.52 24.32 198.4 32 3.84 1.28 7.68 2.56 11.52 2.56 8.96 0 17.92-5.12 21.76-14.08l64-72.96V240.64zM88.32 744.96V250.88c14.08-14.08 52.48-46.08 107.52-64 26.88-8.96 53.76-12.8 81.92-12.8 70.4 0 142.08 26.88 213.76 79.36v477.44c-38.4-23.04-88.32-34.56-149.76-34.56-32 0-66.56 3.84-102.4 10.24-60.16 8.96-115.2 26.88-151.04 38.4zm805.12 79.36c-20.48-5.12-61.44-15.36-106.24-23.04-35.84-5.12-66.56-7.68-94.72-7.68-43.52 0-76.8 6.4-101.12 20.48-15.36 8.96-26.88 20.48-33.28 34.56-33.28 1.28-65.28 2.56-87.04 2.56h-3.84c-6.4-12.8-15.36-24.32-29.44-32-23.04-15.36-58.88-21.76-106.24-21.76-76.8 0-165.12 19.2-200.96 28.16l-29.44-35.84c51.2-17.92 148.48-47.36 240.64-47.36 70.4 0 122.88 17.92 153.6 52.48l2.56 2.56 1.28 1.28 1.28 1.28 1.28 1.28h1.28l2.56 1.28h11.52l2.56-1.28h1.28s1.28 0 1.28-1.28h1.28s1.28 0 1.28-1.28h1.28l2.56-2.56c30.72-37.12 81.92-56.32 152.32-56.32 39.68 0 122.88 6.4 240.64 49.92l-28.16 34.56zm47.36-79.36c-35.84-14.08-90.88-32-152.32-43.52-37.12-6.4-71.68-10.24-103.68-10.24-60.16 0-110.08 12.8-148.48 37.12V253.44c70.4-51.2 142.08-78.08 212.48-78.08 28.16 0 55.04 3.84 81.92 12.8 56.32 17.92 94.72 49.92 110.08 64v492.8z"/></svg><span>23272</span></li>
                    </ul>
                </dd>
</a>
            </dl>
            
            <dl class="clearfix csdn-tracking-statistics recommend_article" data-mod="popu_614" data-poputype="feed"  data-feed-show="false"  data-dsm="post">
<a href="/bcqtt/article/details/75048833"  target="_blank" strategy="BlogCommendFromQuerySearch_7">
                <dd>
                    <h2>关于List.addAll(Collection&lt;E&gt;)方法遇到的问题</h2>
                    <div class="summary">
                        有一个需求，需要将热词信息跟自定义的热词信息（另外一个实体的信息）合并到一个列表里，获取hotKeyList的代码List&lt;HotKeys&gt; hotKeyList = hotKeysDao.getAllHotKeys();获取自定义热词的代码： List&lt;AdInfoExt&gt;...
                    </div>
                    <ul>
                        <li class="avatar_img"><img src="http://avatar.csdn.net/2/1/D/2_bactryki28.jpg" alt="Bactryki28" title="Bactryki28"></li>
                        <li class="user_name">Bactryki28</li>
                        <li class="time">2017-07-13 11:40</li>
                        <li class="visited_num"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"   fill = "#ccc"><defs><style/></defs><path d="M988.16 240.64c0-5.12-2.56-11.52-6.4-15.36-2.56-2.56-51.2-55.04-135.68-81.92-32-10.24-64-15.36-96-15.36-97.28 0-181.76 46.08-235.52 84.48-55.04-39.68-139.52-85.76-236.8-85.76-32 0-65.28 5.12-96 15.36C97.28 168.96 49.92 224 47.36 226.56c-3.84 3.84-5.12 8.96-5.12 15.36v546.56l60.16 71.68c3.84 8.96 12.8 15.36 21.76 15.36 3.84 0 7.68 0 10.24-2.56 19.2-5.12 120.32-29.44 199.68-29.44 37.12 0 64 5.12 79.36 15.36 7.68 5.12 11.52 10.24 12.8 16.64 0 12.8 10.24 23.04 23.04 23.04h21.76c24.32 0 61.44 0 98.56-2.56h5.12c10.24 0 20.48-7.68 23.04-17.92 2.56-10.24 7.68-16.64 17.92-23.04 16.64-8.96 42.24-14.08 76.8-14.08 78.08 0 171.52 24.32 198.4 32 3.84 1.28 7.68 2.56 11.52 2.56 8.96 0 17.92-5.12 21.76-14.08l64-72.96V240.64zM88.32 744.96V250.88c14.08-14.08 52.48-46.08 107.52-64 26.88-8.96 53.76-12.8 81.92-12.8 70.4 0 142.08 26.88 213.76 79.36v477.44c-38.4-23.04-88.32-34.56-149.76-34.56-32 0-66.56 3.84-102.4 10.24-60.16 8.96-115.2 26.88-151.04 38.4zm805.12 79.36c-20.48-5.12-61.44-15.36-106.24-23.04-35.84-5.12-66.56-7.68-94.72-7.68-43.52 0-76.8 6.4-101.12 20.48-15.36 8.96-26.88 20.48-33.28 34.56-33.28 1.28-65.28 2.56-87.04 2.56h-3.84c-6.4-12.8-15.36-24.32-29.44-32-23.04-15.36-58.88-21.76-106.24-21.76-76.8 0-165.12 19.2-200.96 28.16l-29.44-35.84c51.2-17.92 148.48-47.36 240.64-47.36 70.4 0 122.88 17.92 153.6 52.48l2.56 2.56 1.28 1.28 1.28 1.28 1.28 1.28h1.28l2.56 1.28h11.52l2.56-1.28h1.28s1.28 0 1.28-1.28h1.28s1.28 0 1.28-1.28h1.28l2.56-2.56c30.72-37.12 81.92-56.32 152.32-56.32 39.68 0 122.88 6.4 240.64 49.92l-28.16 34.56zm47.36-79.36c-35.84-14.08-90.88-32-152.32-43.52-37.12-6.4-71.68-10.24-103.68-10.24-60.16 0-110.08 12.8-148.48 37.12V253.44c70.4-51.2 142.08-78.08 212.48-78.08 28.16 0 55.04 3.84 81.92 12.8 56.32 17.92 94.72 49.92 110.08 64v492.8z"/></svg><span>2738</span></li>
                    </ul>
                </dd>
</a>
            </dl>
            
            <dl class="clearfix csdn-tracking-statistics recommend_article" data-mod="popu_614" data-poputype="feed"  data-feed-show="false"  data-dsm="post">
<a href="/yang_song_song/article/details/77164948"  target="_blank" strategy="BlogCommendFromQuerySearch_8">
                <dd>
                    <h2>Android7.0解决 android.os.FileUriExposedException: file:///storage/emulated/0/</h2>
                    <div class="summary">
                        解决Android N文件访问crash android.os.FileUriExposedException file:///storage/emulated/0/xxx原因：Android N对访问文件权限收回，按照Android N的要求，若要在应用间共享文件，您应发送一项 content:/...
                    </div>
                    <ul>
                        <li class="avatar_img"><img src="http://avatar.csdn.net/2/9/6/2_yang_song_song.jpg" alt="yang_song_song" title="yang_song_song"></li>
                        <li class="user_name">yang_song_song</li>
                        <li class="time">2017-08-14 18:27</li>
                        <li class="visited_num"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"   fill = "#ccc"><defs><style/></defs><path d="M988.16 240.64c0-5.12-2.56-11.52-6.4-15.36-2.56-2.56-51.2-55.04-135.68-81.92-32-10.24-64-15.36-96-15.36-97.28 0-181.76 46.08-235.52 84.48-55.04-39.68-139.52-85.76-236.8-85.76-32 0-65.28 5.12-96 15.36C97.28 168.96 49.92 224 47.36 226.56c-3.84 3.84-5.12 8.96-5.12 15.36v546.56l60.16 71.68c3.84 8.96 12.8 15.36 21.76 15.36 3.84 0 7.68 0 10.24-2.56 19.2-5.12 120.32-29.44 199.68-29.44 37.12 0 64 5.12 79.36 15.36 7.68 5.12 11.52 10.24 12.8 16.64 0 12.8 10.24 23.04 23.04 23.04h21.76c24.32 0 61.44 0 98.56-2.56h5.12c10.24 0 20.48-7.68 23.04-17.92 2.56-10.24 7.68-16.64 17.92-23.04 16.64-8.96 42.24-14.08 76.8-14.08 78.08 0 171.52 24.32 198.4 32 3.84 1.28 7.68 2.56 11.52 2.56 8.96 0 17.92-5.12 21.76-14.08l64-72.96V240.64zM88.32 744.96V250.88c14.08-14.08 52.48-46.08 107.52-64 26.88-8.96 53.76-12.8 81.92-12.8 70.4 0 142.08 26.88 213.76 79.36v477.44c-38.4-23.04-88.32-34.56-149.76-34.56-32 0-66.56 3.84-102.4 10.24-60.16 8.96-115.2 26.88-151.04 38.4zm805.12 79.36c-20.48-5.12-61.44-15.36-106.24-23.04-35.84-5.12-66.56-7.68-94.72-7.68-43.52 0-76.8 6.4-101.12 20.48-15.36 8.96-26.88 20.48-33.28 34.56-33.28 1.28-65.28 2.56-87.04 2.56h-3.84c-6.4-12.8-15.36-24.32-29.44-32-23.04-15.36-58.88-21.76-106.24-21.76-76.8 0-165.12 19.2-200.96 28.16l-29.44-35.84c51.2-17.92 148.48-47.36 240.64-47.36 70.4 0 122.88 17.92 153.6 52.48l2.56 2.56 1.28 1.28 1.28 1.28 1.28 1.28h1.28l2.56 1.28h11.52l2.56-1.28h1.28s1.28 0 1.28-1.28h1.28s1.28 0 1.28-1.28h1.28l2.56-2.56c30.72-37.12 81.92-56.32 152.32-56.32 39.68 0 122.88 6.4 240.64 49.92l-28.16 34.56zm47.36-79.36c-35.84-14.08-90.88-32-152.32-43.52-37.12-6.4-71.68-10.24-103.68-10.24-60.16 0-110.08 12.8-148.48 37.12V253.44c70.4-51.2 142.08-78.08 212.48-78.08 28.16 0 55.04 3.84 81.92 12.8 56.32 17.92 94.72 49.92 110.08 64v492.8z"/></svg><span>2781</span></li>
                    </ul>
                </dd>
</a>
            </dl>
            
            <dl class="clearfix csdn-tracking-statistics recommend_article" data-mod="popu_614" data-poputype="feed"  data-feed-show="false"  data-dsm="post">
<a href="/a2ni5kfdaio1e6/article/details/78992975"  target="_blank" strategy="BlogCommendFromQuerySearch_9">
                <dd>
                    <h2>早知芯片有漏洞？英特尔CEO去年大幅减持股票</h2>
                    <div class="summary">
                        多家外媒报道，美国英特尔公司首席执行官布赖恩&#183;克拉尼奇去年大幅减持英特尔股票。此前，英特尔已经知道其芯片存在重要安全漏洞。
　　根据美国证券交易委员会去年11月底的一份文件，克拉尼奇行使期权，以每股44.05美元的加权平均价出售644135股英特尔股票。期权曾允许他以每股12.985美元至...
                    </div>
                    <ul>
                        <li class="avatar_img"><img src="http://avatar.csdn.net/B/5/A/2_a2ni5kfdaio1e6.jpg" alt="a2Ni5KFDaIO1E6" title="a2Ni5KFDaIO1E6"></li>
                        <li class="user_name">a2Ni5KFDaIO1E6</li>
                        <li class="time">2018-01-07 08:16</li>
                        <li class="visited_num"><svg class="icon" viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="16" height="16"   fill = "#ccc"><defs><style/></defs><path d="M988.16 240.64c0-5.12-2.56-11.52-6.4-15.36-2.56-2.56-51.2-55.04-135.68-81.92-32-10.24-64-15.36-96-15.36-97.28 0-181.76 46.08-235.52 84.48-55.04-39.68-139.52-85.76-236.8-85.76-32 0-65.28 5.12-96 15.36C97.28 168.96 49.92 224 47.36 226.56c-3.84 3.84-5.12 8.96-5.12 15.36v546.56l60.16 71.68c3.84 8.96 12.8 15.36 21.76 15.36 3.84 0 7.68 0 10.24-2.56 19.2-5.12 120.32-29.44 199.68-29.44 37.12 0 64 5.12 79.36 15.36 7.68 5.12 11.52 10.24 12.8 16.64 0 12.8 10.24 23.04 23.04 23.04h21.76c24.32 0 61.44 0 98.56-2.56h5.12c10.24 0 20.48-7.68 23.04-17.92 2.56-10.24 7.68-16.64 17.92-23.04 16.64-8.96 42.24-14.08 76.8-14.08 78.08 0 171.52 24.32 198.4 32 3.84 1.28 7.68 2.56 11.52 2.56 8.96 0 17.92-5.12 21.76-14.08l64-72.96V240.64zM88.32 744.96V250.88c14.08-14.08 52.48-46.08 107.52-64 26.88-8.96 53.76-12.8 81.92-12.8 70.4 0 142.08 26.88 213.76 79.36v477.44c-38.4-23.04-88.32-34.56-149.76-34.56-32 0-66.56 3.84-102.4 10.24-60.16 8.96-115.2 26.88-151.04 38.4zm805.12 79.36c-20.48-5.12-61.44-15.36-106.24-23.04-35.84-5.12-66.56-7.68-94.72-7.68-43.52 0-76.8 6.4-101.12 20.48-15.36 8.96-26.88 20.48-33.28 34.56-33.28 1.28-65.28 2.56-87.04 2.56h-3.84c-6.4-12.8-15.36-24.32-29.44-32-23.04-15.36-58.88-21.76-106.24-21.76-76.8 0-165.12 19.2-200.96 28.16l-29.44-35.84c51.2-17.92 148.48-47.36 240.64-47.36 70.4 0 122.88 17.92 153.6 52.48l2.56 2.56 1.28 1.28 1.28 1.28 1.28 1.28h1.28l2.56 1.28h11.52l2.56-1.28h1.28s1.28 0 1.28-1.28h1.28s1.28 0 1.28-1.28h1.28l2.56-2.56c30.72-37.12 81.92-56.32 152.32-56.32 39.68 0 122.88 6.4 240.64 49.92l-28.16 34.56zm47.36-79.36c-35.84-14.08-90.88-32-152.32-43.52-37.12-6.4-71.68-10.24-103.68-10.24-60.16 0-110.08 12.8-148.48 37.12V253.44c70.4-51.2 142.08-78.08 212.48-78.08 28.16 0 55.04 3.84 81.92 12.8 56.32 17.92 94.72 49.92 110.08 64v492.8z"/></svg><span>329</span></li>
                    </ul>
                </dd>
</a>
            </dl>
            
</div>
<script type="text/javascript">
    var fileName = '78730200';
    var commentscount = 0;
    var islock = false
document.domain = "csdn.net";
</script>

    <div id="ad_bot">
    </div>
<div id="report_dialog">
</div>

<div id="d-top"  style="bottom:60px;">


        <a id="quick-reply" class="btn btn-top q-reply" title="快速回复" style="display:none;">
            <img src="http://static.blog.csdn.net/images/blog-icon-reply.png" alt="快速回复">
        </a>    
    <a id="d-top-a" class="btn btn-top backtop"  style="display: none;" title="返回顶部" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_huidaodingbu'])" style="">         
         <img src="http://static.blog.csdn.net/images/top.png" alt="TOP">
    </a>
</div>
<script type="text/javascript">
    $(function ()
    {
        $("#ad_frm_0").height("90px");
        
        setTimeout(function(){
            $("#ad_frm_2").height("200px");
        },1000);    
    });
  
</script>
<style type="text/css">
    .tag_list
    {
        background: none repeat scroll 0 0 #FFFFFF;
        border: 1px solid #D7CBC1;
        color: #000000;
        font-size: 12px;
        line-height: 20px;
        list-style: none outside none;
        margin: 10px 2% 0 1%;
        padding: 1px;
    }
    .tag_list h5
    {
        background: none repeat scroll 0 0 #E0DBD3;
        color: #47381C;
        font-size: 12px;
        height: 24px;
        line-height: 24px;
        padding: 0 5px;
        margin: 0;
    }
    .tag_list h5 a
    {
        color: #47381C;
    }
    .classify
    {
        margin: 10px 0;
        padding: 4px 12px 8px;
    }
    .classify a
    {
        margin-right: 20px;
        white-space: nowrap;
    }
</style>






<div id="pop_win" style="display:none ;position: absolute; z-index: 10000; border: 1px solid rgb(220, 220, 220); top: 222.5px; left: 630px; opacity: 1; background: none 0px 0px repeat scroll rgb(255, 255, 255);">
    
</div>
<div id="popup_mask"></div>
<style>
    #popup_mask
    {
        position: absolute;
        width: 100%;
        height: 100%;
        background: #000;
        z-index: 9999;
        left: 0px;
        top: 0px;
        opacity: 0.3;
        filter: alpha(opacity=30);
        display: none;
    }

</style>





<script type="text/javascript">
    $(function(){        
        
        setTimeout(function(){
            $(".comment_body:contains('回复')").each(function(index,item){
                var u=$(this).text().split('：')[0].toString().replace("回复","")
                var thisComment=$(this);
                if(u)
                {
                    $.getJSON("https://passport.csdn.net/get/nick?callback=?", {users: u}, function(a) {
                        if(a!=null&&a.data!=null&&a.data.length>0)
                        {
                            nick=a.data[0].n; 
                            if(u!=nick)
                            {
                                thisComment.text(thisComment.text().replace(u,nick));  
                            }
                        }       
                    });  
                }
            });         

        },200);  

        setTimeout(function(){
            $(".math").each(function(index,value){$(this).find("span").last().css("color","#fff"); })
        },5000);

        setTimeout(function(){
            $(".math").each(function(index,value){$(this).find("span").last().css("color","#fff"); })
        },10000);

        setTimeout(function(){
            $(".math").each(function(index,value){$(this).find("span").last().css("color","#fff"); })
        },15000);
        
        setTimeout(function(){
            $("a img[src='http://js.tongji.linezing.com/stats.gif']").parent().css({"position":"absolute","left":"50%"});
        },300);
    });

    function loginbox(){
        var $logpop=$("#pop_win");
        $logpop.html('<iframe src="https://passport.csdn.net/account/loginbox?service=http://static.blog.csdn.net/callback.htm" frameborder="0" height="600" width="400" scrolling="no"></iframe>');

        $('#popup_mask').css({
            opacity: 0.5,
            width: $( document ).width() + 'px',
            height:  $( document ).height() + 'px'
        });
        $('#popup_mask').css("display","block");
 
        $logpop.css( {
            top: ($( window ).height() - $logpop.height())/ 2  + $( window 
       ).scrollTop() + 'px',
            left:($( window ).width() - $logpop.width())/ 2
        } );
 
        setTimeout( function () {
            $logpop.show();
            $logpop.css( {
                opacity: 1
            } );
        }, 200 );
 
        $('#popup_mask').unbind("click");
        $('#popup_mask').bind("click", function(){
            $('#popup_mask').hide();
            var $clopop = $("#pop_win");
            $("#common_ask_div_sc").css("display","none");
            $clopop.css( {
                opacity: 0
            } );
            setTimeout( function () {
                $clopop.hide();
            }, 350 );
            return false;
        });
    }   
    var showTexComDom = $('<div class="texCommend" style="position:absolute;display:none;">显示当前公式源码</div>');
    $('body').append(showTexComDom);
    $("#article_content").on('contextmenu', 'span.MathJax', function (ev) {
        ev.preventDefault ? ev.preventDefault() : (ev.returnValue = false);
        var scrollleft = document.documentElement.scrollLeft || document.body.scrollLeft;
        var scrolltop = document.documentElement.scrollTop || document.body.scrollTop;
        var left = ev.clientX + scrollleft + 10 + "px";
        var top = ev.clientY + scrolltop + 10 + "px";
        showTexComDom.css({
            top: top,
            left: left
        }).show();
        showTexComDom.html('显示当前公式源码');
        var curSpan = $(this);
        var commendId = curSpan.attr('id').replace('-Frame', '');
        console.log(commendId);
        $("body").bind('click', function (ev) {
            console.log(ev);
            var className = ev.originalEvent.target.className;
            if (className.indexOf('texCommend') === -1) {
                showTexComDom.hide();
                $("body").unbind('click');
            }
        });
        showTexComDom.one('click', function () {
            $(this).text($("#" + commendId).html());
        });
    });
        (function () {
            var viewImg = function viewImg(dom) {
                var dom = dom ? dom : 'body';
                var imgDOM = $(dom + ' img');
                var ua = navigator.userAgent.toLowerCase();

                if (imgDOM.length === 0) return false

                if ($('.imgViewDom').length === 0) {
                    $('body').append('<div class="imgViewDom disnone" style="display: none;"><img src=""></div>')
                    $('body').append('<style>.imgViewDom{display:none;position:fixed;top:0;left:0;height:100%;width:100%;z-index:99999999;background: rgba(255, 255, 255,0.8);overflow: auto;display:-webkit-box;-webkit-box-align:center;-webkit-box-pack:center;display:-moz-box;-moz-box-align:center;-moz-box-pack:center;display:-o-box;-o-box-align:center;-o-box-pack:center;display:-ms-box;-ms-box-align:center;-ms-box-pack:center; display:box;box-align:center;box-pack:center;}.imgViewDom img{cursor: zoom-out;}</style>')
                    $('.imgViewDom').on('click', function () {
                        if (ua.indexOf('windows ') > -1) {
                            $('body').css({ 'overflow': 'auto', 'margin-left': '0' })
                        } else {
                            $('body').css({ 'overflow': 'auto' })
                        }
                        $('.imgViewDom').fadeOut(500).children('img').attr('src', "");
                    })
                }
                imgDOM.bind('click', function (e) {
                    if (e.currentTarget.src) {
                        $('.imgViewDom').fadeIn(500).children('img').css({ 'width': e.currentTarget.naturalWidth, 'height': e.currentTarget.naturalheight }).attr('src', e.currentTarget.src)
                        if (ua.indexOf('windows ') > -1) {
                            $('body').css({ 'overflow': 'hidden', 'margin-left': '-17px' })
                        } else {
                            $('body').css({ 'overflow': 'hidden' })
                        }

                    }
                })

            }
            window.CSDNviewImg = viewImg;

        })()
    CSDNviewImg('#article_details')
    var articletitle='Python 3 多线程下载百度图片搜索结果';

</script>
<script src="http://c.csdnimg.cn/public/common/append_mark/appendMark.min.js?v=5.00.43" type="text/javascript"></script>
<script type="text/javascript">
    appendMark($('.recommend_list').children('a').find('dt'),$('.extension_other'))
</script>









                    <div class="clear">
                    </div>
                </div>

            </div>

            <div id="side">
                

    <div class="side">

<div id="panel_Profile" class="panel">
<ul class="panel_head"><span>个人资料</span></ul>
<ul class="panel_body profile">
<div id="blog_userface">
    <a href="http://my.csdn.net/guyuealian" target="_blank">
    <img src="http://avatar.csdn.net/F/C/D/1_guyuealian.jpg" title="访问我的空间" style="max-width:90%"/>
    </a>
    <br />
    <span><a href="http://my.csdn.net/guyuealian" class="user_name" target="_blank">guyuealian</a></span>
</div>
<div class="interact">

    <a href="javascript:void(0);" class="attent" id="span_add_follow" title="[加关注]"></a>

 <a href="javascript:void(0);" class="letter"  title="[发私信]" onclick="window.open('http://msg.csdn.net/letters/model?receiver=guyuealian','_blank','height=350,width=700');_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_sixin'])"></a>  
</div>
<div id="blog_medal">
                       <div class="ico_expert"  onclick="javascript:location='http://blog.csdn.net/experts/rule.html'" title="CSDN认证专家" style="cursor:pointer;width:60px;height:60px;background:url('http://c.csdnimg.cn/jifen/images/xunzhang/xunzhang/bokezhuanjiamiddle.png') no-repeat" ></div>
                <div id="bms_box">
                                            <a  target="_blank">
                                                    <img src="http://c.csdnimg.cn/jifen/images/xunzhang/xunzhang/zhuanlandaren.png" onmouseover="m_over_m(this,2)" onmouseout="m_out_m()" alt="2" >
                                            </a>
                                            <a  target="_blank">
                                                    <img src="http://c.csdnimg.cn/jifen/images/xunzhang/xunzhang/chizhiyiheng.png" onmouseover="m_over_m(this,4)" onmouseout="m_out_m()" alt="4" >
                                            </a>
               </div>

</div>
<ul id="blog_rank">
    <li>访问：<span>533025次</span></li>
    <li>积分：<span>5740</span> </li>    
    <li >等级： <span style="position:relative;display:inline-block;z-index:1" >
                 <a title="6级,点击查看等级说明" href="http://blog.csdn.net/home/help.html#level" target="_blank"><img src="http://c.csdnimg.cn/jifen/images/xunzhang/jianzhang/blog6.png?v1" alt="" style="vertical-align: middle;" id="leveImg"></a>
            
        </span>  </li>
    <li>排名：<span>第5331名</span></li>
</ul>
<ul id="blog_statistics">
    <li>原创：<span>106篇</span></li>
    <li>转载：<span>51篇</span></li>
    <li>译文：<span>1篇</span></li>
    <li>评论：<span>173条</span></li>
</ul>
</ul>
</div>


                        
<div id="panel_Category" class="panel">
    <ul class="panel_head"><span>博客专栏</span></ul>
    <ul class="panel_body" id="sp_column">
    <table cellpadding="0" cellspacing="0"><tr>
    <td style="padding:10px 10px 0 0;">
    <a href="http://blog.csdn.net/column/details/15916.html" target="_blank"><img src="http://img.blog.csdn.net/column" style="width:75px;height:75px;" /></a>
    </td>
    <td style="padding:10px 0; vertical-align:top;">
    <a href="http://blog.csdn.net/column/details/15916.html" target="_blank">图像识别</a>
    <p>文章：26篇</p>
    <span>阅读：66102</span>
    </td>
    </tr></table>
    </ul>
</div><div class="panel" id="panel_Search">
    <ul class="panel_head"><span>文章搜索</span></ul>
    <ul class="panel_body" class="form_search">
        <form id="frmSearch" class="form_search csdn-tracking-statistics" data-pid="blog"  target="_blank"  data-mod="popu_306">
        <span><input id="inputSearch" type="text" class="blogsearch" title="请输入关键字" /></span>
        <input id="btnSubmit" type="button" value="搜索" title="search in blog" />
        </form>
    </ul>
</div>

<script type="text/javascript">

   
    $(function () {
        $("#btnSubmit").unbind("click");
        $("#btnSubmit").click(function () {           
            search();
        });

        $("#frmSearch").submit(function () {           
            search();
            return false;
        });

        function search()
        {
            if ($("#inputSearch").val() == "") {               
                alert("请录入搜索关键词！");                         
                return false;
            }
            //var url = "http://so.csdn.net/so/search/s.do?q=" + encodeURIComponent($("#inputSearch").val()) + "&u=" + username + "&t=blog";           
            var url = "https://www.baidu.com/s?wd=" + encodeURIComponent($("#inputSearch").val()) + "%20site%3Ablog.csdn.net"
            var url = "/" + username + "?q=" + encodeURIComponent($("#inputSearch").val());
            window.location.href = url;
        }   
    });
</script> 
<div id="panel_Category" class="panel">
<ul class="panel_head"><span>文章分类</span></ul>
<ul class="panel_body">    
                 <li>
                    <a href="/guyuealian/article/category/5603353" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">经验分享</a><span>(21)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/5603355" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">Android</a><span>(38)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6239404" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">机器学习</a><span>(27)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/5645377" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">java开发</a><span>(25)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6049617" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">C / C++</a><span>(18)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6075936" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">SQL数据库</a><span>(6)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6183534" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">求职面试</a><span>(3)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6207388" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">网络技术</a><span>(4)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6299855" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">Hadoop</a><span>(2)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6428363" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">Python</a><span>(5)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6544860" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">软件编程</a><span>(2)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6652939" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">其他文章</a><span>(1)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6655975" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">Matlab</a><span>(8)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6758433" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">信号处理</a><span>(1)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6800062" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">OpenCV</a><span>(19)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6908611" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">图像处理</a><span>(14)</span>
                </li>
                 <li>
                    <a href="/guyuealian/article/category/6990380" onclick="_gaq.push(['_trackEvent','function', 'onclick', 'blog_articles_wenzhangfenlei']); ">心得杂谈</a><span>(1)</span>
                </li>
</ul>
</div>
<div id="panel_Archive" class="panel">
<ul class="panel_head"><span>文章存档</span></ul>
<ul class="panel_body">
<div id="archive_list">
<!--归档统计-->
<li><a href="/guyuealian/article/month/2018/01">2018年01月</a><span>(1)</span></li><li><a href="/guyuealian/article/month/2017/12">2017年12月</a><span>(8)</span></li><li><a href="/guyuealian/article/month/2017/11">2017年11月</a><span>(4)</span></li><li><a href="/guyuealian/article/month/2017/10">2017年10月</a><span>(2)</span></li><li><a href="/guyuealian/article/month/2017/09">2017年09月</a><span>(7)</span></li><li><a href="/guyuealian/article/month/2017/08">2017年08月</a><span>(4)</span></li><li><a href="/guyuealian/article/month/2017/07">2017年07月</a><span>(1)</span></li><li><a href="/guyuealian/article/month/2017/06">2017年06月</a><span>(6)</span></li><li><a href="/guyuealian/article/month/2017/05">2017年05月</a><span>(9)</span></li><li><a href="/guyuealian/article/month/2017/04">2017年04月</a><span>(2)</span></li><li><a href="/guyuealian/article/month/2017/03">2017年03月</a><span>(8)</span></li><li><a href="/guyuealian/article/month/2017/01">2017年01月</a><span>(2)</span></li><li><a href="/guyuealian/article/month/2016/12">2016年12月</a><span>(5)</span></li><li><a href="/guyuealian/article/month/2016/11">2016年11月</a><span>(6)</span></li><li><a href="/guyuealian/article/month/2016/10">2016年10月</a><span>(4)</span></li><li><a href="/guyuealian/article/month/2016/09">2016年09月</a><span>(6)</span></li><li><a href="/guyuealian/article/month/2016/08">2016年08月</a><span>(3)</span></li><li><a href="/guyuealian/article/month/2016/07">2016年07月</a><span>(14)</span></li><li><a href="/guyuealian/article/month/2016/06">2016年06月</a><span>(14)</span></li><li><a href="/guyuealian/article/month/2016/05">2016年05月</a><span>(7)</span></li><li><a href="/guyuealian/article/month/2016/04">2016年04月</a><span>(11)</span></li><li><a href="/guyuealian/article/month/2016/03">2016年03月</a><span>(7)</span></li><li><a href="/guyuealian/article/month/2016/02">2016年02月</a><span>(4)</span></li><li><a href="/guyuealian/article/month/2016/01">2016年01月</a><span>(4)</span></li><li><a href="/guyuealian/article/month/2015/12">2015年12月</a><span>(1)</span></li><li><a href="/guyuealian/article/month/2015/07">2015年07月</a><span>(17)</span></li><li><a href="/guyuealian/article/month/2015/06">2015年06月</a><span>(1)</span></li>
</div>
</ul>
</div>

<div id="hotarticls" class="panel csdn-tracking-statistics" data-pid="blog"  data-mod="popu_340">
<ul class="panel_head">
    <span>       
阅读排行    </span>
</ul>

<ul class="panel_body itemlist">
<li>
<a href="/guyuealian/article/details/51113133" title="Java实现数组反转翻转的方法">Java实现数组反转翻转的方法</a><span>(32098)</span>
</li>
<li>
<a href="/guyuealian/article/details/50762996" title="Eclipse配置Tomcat服务器，通用方法">Eclipse配置Tomcat服务器，通用方法</a><span>(31214)</span>
</li>
<li>
<a href="/guyuealian/article/details/51119499" title="Java单链表反转 详细过程">Java单链表反转 详细过程</a><span>(29913)</span>
</li>
<li>
<a href="/guyuealian/article/details/51345950" title="简单操作只需10秒破解PDF加密文件">简单操作只需10秒破解PDF加密文件</a><span>(25421)</span>
</li>
<li>
<a href="/guyuealian/article/details/46770387" title="Tomcat 输入http://localhost:8080打不开网页的解决方法">Tomcat 输入http://localhost:8080打不开网页的解决方法</a><span>(18052)</span>
</li>
<li>
<a href="/guyuealian/article/details/52504245" title="Microsoft Office Professional Plus 2010在安装中出错 解决办法 安装office2010出错">Microsoft Office Professional Plus 2010在安装中出错 解决办法 安装office2010出错</a><span>(17566)</span>
</li>
<li>
<a href="/guyuealian/article/details/50763109" title="Eclipse没有server 配置Tomcat">Eclipse没有server 配置Tomcat</a><span>(16563)</span>
</li>
<li>
<a href="/guyuealian/article/details/70995333" title="Adaboost算法原理分析和实例+代码（简明易懂）">Adaboost算法原理分析和实例+代码（简明易懂）</a><span>(10767)</span>
</li>
<li>
<a href="/guyuealian/article/details/50825381" title="解决安装XMind出现Invalid Configuration Location The configuration area at &#39;C:\Users\Administrator\Applicat">解决安装XMind出现Invalid Configuration Location The configuration area at &#39;C:\Users\Administrator\Applicat</a><span>(10706)</span>
</li>
<li>
<a href="/guyuealian/article/details/46952439" title="android颜色值的表示方法android:background=&quot;#FFFFFFFF&quot;的意思">android颜色值的表示方法android:background=&quot;#FFFFFFFF&quot;的意思</a><span>(10615)</span>
</li>
</ul>
</div>

<div id="homepageArticles" class="panel csdn-tracking-statistics" data-pid="blog"  data-mod="popu_4" style="height:250px;">

    <div id="cpro_u2734133" style="text-align:center;">
      
        <!-- 投放代码 -->
        <script type="text/javascript" src="//cee1.iteye.com/bwlxosfoo.js"></script>
      

    </div>


</div>


<div id="newcomments" class="panel">
<ul class="panel_head"><span>最新评论</span></ul>
<ul class="panel_body itemlist">
    <li>
   
         <a href="/guyuealian/article/details/53708042#comments">聚类算法-最大最小距离算法(实例+代码)</a>
    <p style="margin:0px;"><a href="/guyuealian" class="user_name">guyuealian</a>:
@qq_37287870:不好意思，图中标记有误，应该是将0.5*sqrt(80)改为0.5*sqr...
    </p>
    </li>
    <li>
   
         <a href="/guyuealian/article/details/53708042#comments">聚类算法-最大最小距离算法(实例+代码)</a>
    <p style="margin:0px;"><a href="/qq_37287870" class="user_name">qq_37287870</a>:
请教一下大家，在最后一步归类到第三类时，点X3到点x7的距离：D33为 【根号17】=4.12 是小...
    </p>
    </li>
    <li>
   
         <a href="/guyuealian/article/details/53708042#comments">聚类算法-最大最小距离算法(实例+代码)</a>
    <p style="margin:0px;"><a href="/qq_37287870" class="user_name">qq_37287870</a>:
想要word的版本，邮箱1115245864@qq.com。感激不尽
    </p>
    </li>
    <li>
   
         <a href="/guyuealian/article/details/71440949#comments">Matlab形态学图像处理：二值图像分割 标记连通区域和重心位置 删除连通区域</a>
    <p style="margin:0px;"><a href="/gongrang" class="user_name">gongrang</a>:
如果连通区域黏连在一起，如何进行分割啊？
    </p>
    </li>
    <li>
   
         <a href="/guyuealian/article/details/53672487#comments">张志华教授《机器学习导论》和《统计机器学习》课程讲义</a>
    <p style="margin:0px;"><a href="/anonymity1113" class="user_name">anonymity1113</a>:
@anonymity1113:邮箱:375786734@qq.com十分感谢！
    </p>
    </li>
    <li>
   
         <a href="/guyuealian/article/details/53672487#comments">张志华教授《机器学习导论》和《统计机器学习》课程讲义</a>
    <p style="margin:0px;"><a href="/anonymity1113" class="user_name">anonymity1113</a>:
老哥 能发我一份张志华老师的讲义吗 你给的链接用不了
    </p>
    </li>
    <li>
   
         <a href="/guyuealian/article/details/70995333#comments">Adaboost算法原理分析和实例+代码（简明易懂）</a>
    <p style="margin:0px;"><a href="/gc475668754" class="user_name">gc475668754</a>:
感谢！
    </p>
    </li>
    <li>
   
         <a href="/guyuealian/article/details/70995333#comments">张志华教授《机器学习导论》和《统计机器学习》课程讲义</a>
    <p style="margin:0px;"><a href="/weixin_38591668" class="user_name">weixin_38591668</a>:
楼主，网站和百度网盘都打不开啊！ 能将讲义邮给我学习一下吗？非常感谢感谢！215492800@qq....
    </p>
    </li>
    <li>
   
         <a href="/guyuealian/article/details/51187240#comments">Sysnoise5.6安装教程和破解方法</a>
    <p style="margin:0px;"><a href="/qq_41639855" class="user_name">qq_41639855</a>:
求一个能用的链接，万分感谢。a863018935@qq.com
    </p>
    </li>
    <li>
   
         <a href="/guyuealian/article/details/51187240#comments">聚类算法-最大最小距离算法(实例+代码)</a>
    <p style="margin:0px;"><a href="/liuyan718" class="user_name">liuyan718</a>:
你好，能不能把文档发给我449258197@qq.com
    </p>
    </li>
</ul>
</div>

    </div>
    <div class="clear">
    </div>

                        <div class="csdn-tracking-statistics" data-pid="blog" data-view="true" data-mod="ad_popu_189" data-mtp="63" data-order="40" data-con="ad_content_1259" style="width: 250px; height: 250px;">
                            <div id="nav_show_top_stop" style="width: 250px;height: 250px;z-index:1000">

                                <div id="cpro_u3031286" style="text-align:center;">
                                    <!-- 投放代码 -->
                                    <script type="text/javascript" src="//cee1.iteye.com/bwocoflyv.js"></script>
                                    



                                </div>
                            </div>
                        </div>
                        <script>

                            setTimeout(function () {
                                var naviga_offsetTop = 0; function naviga_stay_top() {
                                    var scrollTop = jQuery(document).scrollTop();
                                    if (scrollTop > naviga_offsetTop) {
                                        jQuery("#nav_show_top_stop").css({ "position": "fixed" });
                                        jQuery("#nav_show_top_stop").css({ "top": "0px" });
                                    } else { jQuery("#nav_show_top_stop").css({ "position": "fixed" }); jQuery("#nav_show_top_stop").css({ "top": naviga_offsetTop - scrollTop + "px" }); }
                                }
                                function onload_function() {
                                    naviga_offsetTop = jQuery("#nav_show_top_stop").position().top;
                                    jQuery(window).bind("scroll", naviga_stay_top); jQuery(window).bind("mousewheel", naviga_stay_top);
                                    jQuery(document).bind("scroll", naviga_stay_top); jQuery(document).bind("mousewheel", naviga_stay_top);
                                } jQuery(document).ready(onload_function);
                            }, 200);

                        </script>

            </div>
            <div class="clear">
            </div>
        </div>

        













<script type="text/javascript">
    $(function () {
        function __get_code_toolbar(snippet_id) {
            return $("<span class='csdn-tracking-statistics' data-pid=\"blog\"  data-mod='popu_167'><a href='https://code.csdn.net/snippets/"
                    + snippet_id
                    + "' target='_blank' title='在CODE上查看代码片'  style='text-indent:0;'><img src='https://code.csdn.net/assets/CODE_ico.png' width=12 height=12 alt='在CODE上查看代码片' style='position:relative;top:1px;left:2px;'/></a></span>"
                + "<span class='csdn-tracking-statistics' data-pid=\"blog\"  data-mod='popu_170'><a href='https://code.csdn.net/snippets/"
                    + snippet_id
                    + "/fork' target='_blank' title='派生到我的代码片' style='text-indent:0;'><img src='https://code.csdn.net/assets/ico_fork.svg' width=12 height=12 alt='派生到我的代码片' style='position:relative;top:2px;left:2px;'/></a></span>");
        }
        
        $("[code_snippet_id]").each(function () {
            __s_id = $(this).attr("code_snippet_id");
            if (__s_id != null && __s_id != "" && __s_id != 0 && parseInt(__s_id) > 70020) {
                __code_tool = __get_code_toolbar(__s_id);
                $(this).prev().find(".tools").append(__code_tool);
            }
        });

        $(".bar").show();
    });
</script>





    </div>



 


    <script src="http://static.blog.csdn.net/scripts/csdn_blog_detail.min.js?v2018.01.30" type="text/javascript"></script>

    <script type="text/javascript" src="http://csdnimg.cn/blog/csdn_public_blog_detail.min.js?20171208116"></script>

    <script type="text/javascript" src="http://medal.blog.csdn.net/showblogmedal.ashx?blogid=5081781"></script>


    <div id="a52b5334d" style="width: 1px; height: 1px; display: none;">
        <script id="adJs52b5334"></script>
        <script>document.getElementById("adJs52b5334").src = "http://ads.csdn.net/js/opt/52b5334.js?t=" + Math.random();</script>
    </div>

    <div class="pop_CA_cover" style="display:none"></div>
    <div class="pop pop_CA" style="display:none">
        <div class="CA_header">
            收藏助手
            <span class="cancel_icon" id="fapancle" onclick="$('.pop_CA').hide();$('.pop_CA_cover').hide();"></span>
        </div>
        <iframe src="" id="fa" frameborder="0" width="100%" height="360" scrolling="no"></iframe>
    </div>


        <script type="text/javascript">

            $(function () {
                var fromjs = $("#fromjs");
                if (fromjs.length > 0) {
                    $("#fromjs .markdown_views pre").addClass("prettyprint");
                    prettyPrint();

                    $('pre.prettyprint code').each(function () {
                        var lines = $(this).text().split('\n').length;
                        var $numbering = $('<ul/>').addClass('pre-numbering').hide();
                        $(this).addClass('has-numbering').parent().append($numbering);
                        for (i = 1; i <= lines; i++) {
                            $numbering.append($('<li/>').text(i));
                        };
                        $numbering.fadeIn(1700);
                    });

                    $('.pre-numbering li').css("color", "#999");
                }
            });

            $(".markdown_views a[target!='_blank']").attr("target", "_blank");

            //$(".toc a[target='_blank']").attr("target", "");

            setTimeout(function () {
                $(".toc a[target='_blank']").attr("target", "");
            }, 500);

        </script>
    <div style="display:none;">
        <img src="" onerror='setTimeout(function(){if(top !== self){window["\x74\x6f\x70"]["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x68\x72\x65\x66"] = window["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x68\x72\x65\x66"];}            if(typeof(csdn)=="\x75\x6e\x64\x65\x66\x69\x6e\x65\x64"&&window["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x68\x6f\x73\x74"]["\x69\x6e\x64\x65\x78\x4f\x66"]("\x63\x73\x64\x6e\x2e\x6e\x65\x74")<0&&window["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x68\x6f\x73\x74"]["\x69\x6e\x64\x65\x78\x4f\x66"]("\x69\x74\x65\x79\x65\x2e\x63\x6f\x6d")<0){window["\x6c\x6f\x63\x61\x74\x69\x6f\x6e"]["\x68\x72\x65\x66"]="\x68\x74\x74\x70\x73\x3a\x2f\x2f\x77\x77\x77\x2e\x63\x73\x64\x6e\x2e\x6e\x65\x74";}},3000);'>
    </div>
</body>
</html>
